javascript - Unable to get html links with cURL -
I am trying to get a link from a website. When I try to connect through the terminal, I get this message, you have to turn on javascript and cookies support in the browser to visit this site. I've tried stack overflow and all the different codes around Google that no one is doing the job as I would love it. None of them is receiving any data from this website, which I try to get data. Other sites work
& lt ;? Php function get_url ($ url, $ javascript_loop = 0, $ timeout = 5) {$ url = str_replace ("&", "& amp;", urldecode trim ($ url)); $ Cookie = tempnam ("/ tmp", "karlokuui"); $ Ch = curl_init (); Curl_setopt ($ ch, CURLOPT_USERAGENT, "Mozilla / 5.0 (Windows; U; Windows NT 5.1; RV: 1.7.3) Gecko / 20041001 Firefox / 0.10.1"); Curl_setopt ($ ch, CURLOPT_URL, $ url); Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookie); Curl_setopt ($ CH, CURLOPT_FOLLOWLOCATION, true); Curl_setopt ($ CH, CURLOPT_ENCODING, ""); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ ch, CURLOPT_AUTOREFERER, true); Curl_setopt ($ CH, CURLOPT_SSL_VERIFYPEER, incorrect); #Https urls are required for curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout); Curl_setopt ($ ch, CURLOPT_TIMEOUT, $ timeout); Curl_setopt ($ CH, CURLOPT_MAXREDIRS, 10); $ Content = curl_exec ($ ch); $ Response = curl_getinfo ($ ch); If (curl_exec ($ ch) === incorrect) {echo 'curl error:'. Curl_error ($ ch); } Curl_close ($ ch); If ($ response ['HTTP_CODE'] == 301 || $ response ['HTTP_CODE'] == 302) {ini_set ("USER_AGENT", "Mozilla / 5.0 (Windows, U, Windows NT 5.1, RV .: 1.7.3) Gecho / 20041001 Firefox / 0.10.1 "); If ($ headers = get_headers ($ response ['url']) {foreach ($ headers as value) {if substr (strtolower ($ value), 0, 9) == "location:") return GET_URL (trim (substr ($ value, 9, strlen ($ value)))); }}} If ((preg_match ("/> [[: space:]] + window \ .location \ .replace \ ('. (*)' \ / /" $, $ Content, $ value) || Preg_match ("/>[[[space:]]+window\.location\=\"(.*)\"/i", $ content, $ value) & amp; $ javascript_loop & lt; 5) {return Get_url ($ value [1], $ javascript_loop + 1); } Other {Return Array ($ Content, $ Reaction); }} $ Test = get_url ('http://livefootball.ws'); Print_r ($ test); ? & Gt;
If I switch the URL to another website, I get the result, but this is not working from this website. Any help would be appreciated.
After
CURLOPT_COOKIEFILE
also pointing to your $ Cookie
and make sure you have permissions for the server to be able to write that file. This cookie can take care of the problem but as far as Javascript is concerned, I think you are out of luck.
Comments
Post a Comment