tags:

views:

37

answers:

1

i am using curl and i am passing url, with page no=2 but it redirect to first page.i need your help please help me

example if i passed= http://itunes.apple.com/us/genre/mobile-software- applications/id6018?mt=8&letter=A&page=2#page

it redirect to= http://itunes.apple.com/us/genre/mobile-software- applications/id6018?mt=8&letter=A&page=1#page

<?php

$agent= 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0';

$ch = curl_init();

curl_setopt($ch, CURLOPT_USERAGENT, $agent);


curl_setopt($ch, CURLOPT_URL, "http://itunes.apple.com/us/genre/mobile-software-  applications/id6018?mt=8&letter=A&page=2#page");  


curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  

curl_setopt($ch, CURLOPT_HEADER, 0);  

curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");


if(curl_exec($ch) === false)
{

  echo 'Curl error: ' . curl_error($ch);
}
else{

  echo $output = curl_exec($ch);  
}

curl_close($ch);  

?>

but it always redirect to first page I am not getting page 2 or given url.

A: 

Try removing the hashed part from your URL:

#page

so that the URL looks like so:

curl_setopt($ch, CURLOPT_URL, "http://itunes.apple.com/us/genre/mobile-software-
applications/id6018?mt=8&letter=A&page=2");

(line break added for readability)

the hash part must never be sent to the server, it is used by the browser to navigate to parts of the page.

Pekka
thanks Pekka I am heartly thanks to you..once agian thanks.
Sushant Panigrahi