curl - How to disguise your PHP script as a browser? -


we've been using information site while (something site allows if mention source , do) , we've been copying information hand. imagine can become tedious pretty fast i've been trying automate process fetching information php script.

the url i'm trying fetch is:

http://mediaforest.ro/weeklycharts/viewchart.aspx?r=weeklychartradiolocal&y=2010&w=46 08-11-10 14-11-10 

if enter in browser works, if try file_get_contents() bad request

i figured checked see if client browser rolled curl based solution:

$ch = curl_init();  $header=array(   'user-agent: mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9.2.12) gecko/20101026 firefox/3.6.12',   'accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',   'accept-language: en-us,en;q=0.5',   'accept-encoding: gzip,deflate',   'accept-charset: iso-8859-1,utf-8;q=0.7,*;q=0.7',   'keep-alive: 115',   'connection: keep-alive', );  curl_setopt($ch,curlopt_url,$url); curl_setopt($ch,curlopt_returntransfer,true); curl_setopt($ch,curlopt_cookiefile,'cookies.txt'); curl_setopt($ch,curlopt_cookiejar,'cookies.txt'); curl_setopt($ch,curlopt_httpheader,$header); $result=curl_exec($ch);  curl_close($ch); 

i've checked , headers identical browser's headers , still bad request

so tried solution:

http://www.php.net/manual/en/function.curl-setopt.php#78046 

unfortunately doesn't work either , i'm out of ideas. missing?

try escaping url, works me way.

http://mediaforest.ro/weeklycharts/viewchart.aspx?r=weeklychartradiolocal&y=2010&w=46%2008-11-10%2014-11-10 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -