Hi there,
I would like to save to disk a picture contained in a webpage.
Unfortunately the image is dynamic, so the url is actually a query
which looks like http://adfarm.mediaplex.com/ad/bn/23...68644406357385
rather than the standard http://img-cdn.mediaplex.com/ads/239...on_120x600.gif
I've been told that a scripting language like Perl, Python or PHP is
my best bet for this kind of tasks, would you agree?
Could you please give a few function names to look at as a starting
point?
That should suffice, although a code snippet would be greatly
appreciated.
;)
Thank you very much in advance for your help.
Regards,
Giulio 7 4669
Giulio Cespuglio: I would like to save to disk a picture contained in a webpage.
Unfortunately the image is dynamic, so the url is actually a query which looks like
http://adfarm.mediaplex.com/ad/bn/23...68644406357385
rather than the standard
http://img-cdn.mediaplex.com/ads/239...on_120x600.gif
That doesn't matter at all.
I've been told that a scripting language like Perl, Python or PHP is my best bet for this kind of tasks, would you agree?
Absolutely! :-)
Could you please give a few function names to look at as a starting point? That should suffice, although a code snippet would be greatly appreciated.
Try running this code and see what you think:
#########################
import urllib
def saveUrlToFile( url, fileName ):
f = open( fileName, 'wb' )
data = urllib.urlopen(url).read()
f.write( data )
f.close()
saveUrlToFile(
'http://adfarm.mediaplex.com/ad/bn/2397-11787-1843-5?mpt=1068644406357385',
'test.gif' )
#########################
-Mike
Giulio Cespuglio wrote: I would like to save to disk a picture contained in a webpage.
Unfortunately the image is dynamic, so the url is actually a query which looks like
http://adfarm.mediaplex.com/ad/bn/23...68644406357385
rather than the standard
http://img-cdn.mediaplex.com/ads/239...on_120x600.gif
Unless you have more requirements that you did not mention, I fail
to see why this is a problem, and why you have to write a program
to do this.
Right click the image, 'save image as'.
Or use a tool such as wget or curl to directly download
the URL above, even the 'dynamic one'.
--Irmen
> saveUrlToFile(
'http://adfarm.mediaplex.com/ad/bn/2397-11787-1843-5?mpt=1068644406357385', 'test.gif' )
That got formatted oddly for some reason, although it should still work.
-Mike
>>>>> "Michael" == Michael Geary <Mi**@DeleteThis.Geary.com> writes:
Michael> Try running this code and see what you think:
You mean
import urllib
urllib.urlretrieve(url, filename)
right?
<wink>,
JDH
John Hunter wrote: You mean
import urllib urllib.urlretrieve(url, filename)
right?
<wink>, JDH
Oh! Thank you--that's much better than the code I posted. :-)
-Mike
Irmen de Jong <irmen@-NOSPAM-REMOVETHIS-xs4all.nl> wrote in message news:<3f***********************@news.xs4all.nl>... Giulio Cespuglio wrote:
I would like to save to disk a picture contained in a webpage.
Unfortunately the image is dynamic, so the url is actually a query which looks like
http://adfarm.mediaplex.com/ad/bn/23...68644406357385
rather than the standard
http://img-cdn.mediaplex.com/ads/239...on_120x600.gif
Unless you have more requirements that you did not mention, I fail to see why this is a problem, and why you have to write a program to do this.
Right click the image, 'save image as'.
Or use a tool such as wget or curl to directly download the URL above, even the 'dynamic one'.
--Irmen
you did miss it, he needs to do it with Python as do I anyone have a
helpful piece of code that works as an example?
>>>>> "Y2KYZFR1" == Y2KYZFR1 <ja*************@yahoo.com> writes: > Unfortunately the image is dynamic, so the url is actually a query > which looks like
http://adfarm.mediaplex.com/ad/bn/23...68644406357385 > > rather than the standard > > http://img-cdn.mediaplex.com/ads/239...on_120x600.gif
If the query is dynamic, you may need to sniff the HTTP headers to
find out what is going on behind the scenes. Mozilla Firebird has a
'Live HTTP Headers' addon module that lets you captue and save the
headers as you browse. You can then sort through them, find out what
is going on, and use the httplib module to code it in python.
Not easy, but doable.
JDH This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: S. Stilwell |
last post by:
I'm trying to write a small program that will go to a particular web site
and download an image file on a schedule. I just need to know how to save
the file to disk from a website. Any help would...
|
by: Jacob H |
last post by:
Hello list...
I'm developing an adventure game in Python (which of course is lots of
fun). One of the features is the ability to save games and restore the
saves later. I'm using the pickle...
|
by: MC |
last post by:
How can we save entire html web pages to io streams, including picture files (jpeg, gif, etc.) and other linked files if any.
We need to be able to save to disk entire html pages, not just their...
|
by: Espen Evje |
last post by:
Hi,
I am trying to present the images in a folder as thumbnails in a dynamically
created asp:table.
I however do not want to save the thumbnails to disk, only show the images
in this folder as...
|
by: Laszlo Csabi |
last post by:
Hi guys,
Anyone knows about how to save a picture from a html page to the hard disk
either in C# or VB.NET? What I have done so far is the following and it
doesn't work. I got an empty image...
|
by: Dixon |
last post by:
Hai
Im a newbie
I have a picture in a picture box
I drag a portion of the picture with the mouse.....
Here i get the area i dragged in and now i want that area to be a
separate picture...
|
by: Pedro Leite |
last post by:
Good Afternoon.
the code below is properly retreiving binary data from a database and saving
it. but instead of saving at client machine is saving at the server machine.
what is wrong with my...
|
by: Jeff |
last post by:
Hey
(and thank you for reading my post)
In visual web developer 2005 express edition I've created a simple website
project..
At this website I want users who register to be able to upload a...
|
by: Peter Olcott |
last post by:
So far the only way that I found to do this was by making a
single global instance of the container class and providing
access to the contained class, through this single global
instance. Are...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |