WeirdMystery Posted April 26, 2010 Share Posted April 26, 2010 Hello guys, I am making a page viewer bot. The PHP script will use cURL to visit the site. I've got it working, however, It takes a whole lot of download bandwidth to use it. My question is, when you tell the cURL session to execute and go to the page, is it actually downloading the page server-side? Because I am actually going to make this a public service and I don't want it to waste loads of bandwidth. All I want the script to do is make the site think I've visited the page. <? $url = "examplesite.com"; curl_setopt ($curl, CURLOPT_URL, "$url" ); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1 ); $exec = curl_exec ($curl); curl_close ($curl); ?> Quote Link to comment https://forums.phpfreaks.com/topic/199849-using-curl-to-visit-a-page/ Share on other sites More sharing options...
premiso Posted April 26, 2010 Share Posted April 26, 2010 Yes, that will download the entire page. To just get the page headers you can use this: CURLOPT_NOBODY TRUE to exclude the body from the output. Request method is then set to HEAD. Changing this to FALSE does not change it to GET. With the curl_setopt to just get the headers. Quote Link to comment https://forums.phpfreaks.com/topic/199849-using-curl-to-visit-a-page/#findComment-1049010 Share on other sites More sharing options...
WeirdMystery Posted April 26, 2010 Author Share Posted April 26, 2010 Yes, that will download the entire page. To just get the page headers you can use this: CURLOPT_NOBODY TRUE to exclude the body from the output. Request method is then set to HEAD. Changing this to FALSE does not change it to GET. With the curl_setopt to just get the headers. Thanks man, it took way faster and it took less bandwidth. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/199849-using-curl-to-visit-a-page/#findComment-1049019 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.