The following site is bugging me in my attempts to grab the video titles: http://vbox7.com Whenever you visit a video page with JavaScript (or cookies, but I figured a way to simulate them on) turned off you can not see the video title. A typical video page: http://vbox7.com/play:fd7caa326b If visited without Javascript the page is redirected to:: http://vbox7.com/show:missjavascript?back_to=%2Fplay%3Afd7caa326b Code (markup): Now I want to grab this video title and I am using PHP+cURL. First I grab the video page with cURL and I naturally get the "JS not enabled" page source. It contains code similar to this: <script type="text/javascript"> window.location = '?js=1&token=84c6ba94f8&back_to=%2Fplay%3Afd7caa326b'; </script> Code (markup): I then try to go to grab this page: http://vbox7.com/?js=1&token=230dd03921&back_to=%2Fplay%3Aa5193686a6 Code (markup): I fake the referrer to be the original video play URL and I simulate a Mozilla Firefox user agent. However, in the end I still get the same page which says that Javascript is disabled. Only this time, the page has this redirection Javascript: <script type="text/javascript"> window.location = '?js=1&token=22becb732e&back_to=%2F%3Fjs%3D1%26token%3D22becb732e%26back_to%3D%252Fplay%253Aa5193686a6'; </script> Code (markup): Essentially, an infinite loop... Do you know how to solve this issues - e.g. how to skip the Javascript check or grab the video title in another manner? My full code is this: <?php /* gets the data from a URL */ function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9'); curl_setopt( $ch, CURLOPT_REFERER, 'http://vbox7.com/play:a5193686a6' ); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); curl_setopt($ch,CURLOPT_COOKIEJAR,'./cookie.txt'); curl_setopt($ch,CURLOPT_COOKIEFILE,'./cookie.txt'); $data = curl_exec($ch); curl_close($ch); return $data; } $get = get_data('http://vbox7.com/play:a5193686a6'); //print_r('<textarea cols=100 rows=100>'.$get.'</textarea>'); $parse = explode("window.location = '",$get,2); $parse = explode("'",$parse[1],2); $parse = $parse[0]; $get = get_data('http://vbox7.com/'.$parse); //print_r('<textarea cols=100 rows=100>'.$get.'</textarea>'); ?> PHP:
If the some javascripts is download to execute on local computer and send back the "result" to server. you need to simulate the local computer to get the result of javascripts' execution.
No, I believe it doesn't work with this concept. Besides, I don't think JavaScript has enough permissions to initiate a download without the user's consent.