I want to use php to collect data from a website, but I cannot obtain data from this website. URL: http://www.alldatasheet.com/view.jsp? Searchword = 78HC hope you can give it a try, as long as you can return data. I have tried it for a long time and cannot succeed. How to collect anti-collection websites
I want to use php to collect the data of a website, but I cannot obtain the data of this website. URL:
Http://www.alldatasheet.com/view.jsp? Searchword = 78HC
I hope you can give it a try, as long as you can return data. I have tried it for a long time and cannot succeed.
------ Solution --------------------
$ Header = array (
"GET/view. jsp? Searchword = 78HC HTTP/1.1 ",
"Host: www.alldatasheet.com ",
"Connection: keep-alive ",
"Cache-Control: max-age = 0 ",
"Accept: text/html, application/xhtml + xml, application/xml; q = 0.9, */*; q = 0.8 ",
"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.152 Safari/537.22 ",
"Accept-Encoding: gzip, deflate, sdch ",
"Accept-Language: en-US, zh-CN; q = 0.8, zh; q = 0.6 ",
"Accept-Charset: UTF-8, *; q = 0.5 ",
"Cookie: JSESSIONID = BD1418BC3F4CA9084F0C022A98687A09; track_id = 117.25.173.1113633103000044; seekstr = * 78 H *..;
Seekshot = 78H... 1... 75... 8... 112; _ utma = 191189370.2036196682.1363308553.1363308553.1363308553.1363308553.1;
_ Utmb = 191189370.3.10.1363308553; _ utmc = 191189370; _ utmz = 191189370.1363308553.1.1.utmcsr = (direct)
------ Solution --------------------
Utmccn = (direct)
------ Solution --------------------
Utmcmd = (none); arp_scroll_position = 900"
);
// Initialize a cURL object
$ Curl = curl_init ();
// Set the URL you want to capture
Curl_setopt ($ curl, CURLOPT_URL, 'http: // www.alldatasheet.com/view.jsp? Searchword = 78HC ');
Curl_setopt ($ curl, CURLOPT_HTTPHEADER, $ header); // Set the header
// Sets the header display mode.
Curl_setopt ($ curl, CURLOPT_HEADER, 0 );
// Set the cURL parameter to save the result to the string or output to the screen.
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
// Run cURL to request the webpage
$ Data = curl_exec ($ curl );
// Close the URL request
Curl_close ($ curl );
// Display the obtained data
Var_dump ($ data );
------ Solution --------------------
Pages accessible by browsers can be collected.
The key is cookie.