Dtonlinegames Posted May 30, 2009 Share Posted May 30, 2009 Hey guys I was wondering how youd do something like the W3C checker, like user supplied url and the script checks elements on the page. I dont know where to start with this to be honest. cheers! Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/ Share on other sites More sharing options...
neogemima Posted May 30, 2009 Share Posted May 30, 2009 Wow, that's a REALLY broad question. I would start by reading all information available on whatever code you would like to use to do that. If it were me, and I've never even considered how to build one until two seconds ago, I would create a database that uses php to log all content in one's source file and do some checks that way. You'd have to use scripts that check the header of the file and then check their file based on what type of header they are using. Basically check their content against that header's library of acceptable scripts and see if they match. Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/#findComment-845924 Share on other sites More sharing options...
Ken2k7 Posted May 30, 2009 Share Posted May 30, 2009 I don't know how W3C validates pages, but it would surprise me if they use a language other than PHP to do so. Frankly, I'm not sure how to do all of it with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/#findComment-845928 Share on other sites More sharing options...
thebadbad Posted May 30, 2009 Share Posted May 30, 2009 Yes, you can use cURL to read a remote page's source code, and then 'check' it (whatever that involves) using e.g. regular expressions (using the preg_* functions). A vague answer to a vague question Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/#findComment-845943 Share on other sites More sharing options...
Dtonlinegames Posted May 31, 2009 Author Share Posted May 31, 2009 'm not sure if fopen has the functionality I need it to have but I've never had a reason to use Curl so its a bit like argh! But basically I want to open the supplied URL check it has certain elements and how many of each and give a score at the end of it. I wouldnt really want to store the users data cos of protection etc but I guess I'm going to need a copy of it somewhere to referance and read would probably be faster and sue less bandwidth too. Dunno fopen? or curl? lol Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/#findComment-846306 Share on other sites More sharing options...
thebadbad Posted June 1, 2009 Share Posted June 1, 2009 An example for you: <?php ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; da; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10'); $url = 'http://google.com/'; $source = file_get_contents($url); $count = preg_match_all('~<div[^>]*>~i', $source); echo "$count div elements were found on $url"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/#findComment-847159 Share on other sites More sharing options...
Axeia Posted June 1, 2009 Share Posted June 1, 2009 fopen wont do as you can't check reponse headers with it an if it really is similar to the w3c service you'll want to know the headers as well as sending an UTF-8 header eliminates the need for a meta tag (Unless you're using IE!).. or at least I think it was, been using the meta anyways for IE. Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/#findComment-847216 Share on other sites More sharing options...
Dtonlinegames Posted June 3, 2009 Author Share Posted June 3, 2009 I've used file_get_contents and preg_match_all seemed to give me what I needed just a lot of syntax errors with the wild cards in the preg matches! confusing. its getting there I'll post a link when its done Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/#findComment-848387 Share on other sites More sharing options...
JonnoTheDev Posted June 3, 2009 Share Posted June 3, 2009 file_get_contents() is slow compared to a curl request. Quote Link to comment https://forums.phpfreaks.com/topic/160296-curl/#findComment-848438 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.