Jump to content

Problem downloading image with curl


jumpjack

Recommended Posts

I am not able to download images from this address using Curl:

http://www.sat24.com/image.ashx?sat=vis&type=history&country=it&time=201002021000&sessionid=lu5gewaraqfnw0igmbcb5tuh

 

Note:

that url CANNOT work for you until you'll obtain a new session id: use this page to select the image to download, and drag the image to address bar to read the session id:

http://www.sat24.com/history.aspx?country=it

 

I think the server "knows" the request is coming from a server rather than from clicking on a link. But a link to such an image CAN be inserted into a web page to hot-link the image.

 

Question is: can I configure Curl request in such a way it looks like an hotlinking?

Link to comment
https://forums.phpfreaks.com/topic/190899-problem-downloading-image-with-curl/
Share on other sites

You dont show any code s we dont really know what you are doing. But to pretend you are "hotlinking" set a user-agaent to look like a browser to the connect to server.

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux 2.6.32-7 i586; en-US; m18) Gecko/20010131 Netscape6/6.01 ');

 

otherwise if you set nothing and  dont id yourself you look like a bad bot.

 

 

HTH

Teamaotmic

You dont show any code s we dont really know what you are doing. But to pretend you are "hotlinking" set a user-agaent to look like a browser to the connect to server.

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux 2.6.32-7 i586; en-US; m18) Gecko/20010131 Netscape6/6.01 ');

 

otherwise if you set nothing and  dont id yourself you look like a bad bot.

 

 

HTH

Teamaotmic

 

This is my code.

$ch = curl_init();
$fp = fopen($nomefile, "w");
curl_setopt($ch, CURLOPT_URL, $DATA_PATH);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, 'http://www2.sat24.com/');
curl_setopt($ch, CURLOPT_FILE, $fp);
$immagine = curl_exec($ch);
curl_close($ch);
fclose($fp);

Gonna trying your tips.

 

it does not work.  :-[

 

any more suggestion?

 

All I can do right now is just createing a page containing all links to images I want to download: they are properly displayed, so when I save the full web page, they get saved properly ... but they are all mixed up rather than in viewing order, and they have random names!!!  :'(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.