cURL for .aspx site scraping

I’m toying around with cURL, trying to learn about headers and .aspx. I can normally do a lot with simple_html_dom when it comes to parsing an html file’s content but I’m unable to get “file_get_html” to work in coercion with cURL and the .aspx site. Below is my code… any suggestions would be much appreciated!

[php]include_once(’/simple_html_dom.php’);
$URL=“http://scores.covers.com/ajax/SportsDirect.Controls.LiveScoresControls.Scoreboard,SportsDirect.Controls.LiveScoresControls.ashx?_method=UpdateScoreboard&_session=no”;
$ch = curl_init($URL);
//curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERAGENT, “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1”);
curl_setopt($ch, CURLOPT_POSTFIELDS, “LeagueID=7\r\nGameDate=1-19-2012\r\nSeason=2011-2012\r\nRefresh=true\r\nLastUpdateTime=01-01-1900\r\ntype=Matchups\r\nRefreshStartTime=28-0-2012-1327798352390\r\nWeek=\r\nconferenceID=full”);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);

$html = file_get_html($html);[/php]

You’re not formatting your CURLOPT_POSTFIELDS correctly - replace \r\n with &.

From what I’ve found, I think that the file_get_html function doesn’t parse it from the string that you give it, but takes a URL or path as the parameter.

Sponsor our Newsletter | Privacy Policy | Terms of Service