Question on using urllib

Olivier Scalbert olivier.scalbert at algosyn.com
Thu Nov 11 13:15:19 EST 2010


On 11/11/2010 06:37 PM, Peter Otten wrote:

> The problem is indeed not Python-related. The provider of the images doesn't 
> like what you're trying to do and verifies the referer, i. e. that the page 
> you claim to be coming from is acceptable. Here's one way to satisfy that 
> check:
> 
>>>> from urllib2 import Request, urlopen
>>>> r = Request("http://www.infometeo.be/img.php?iid=1057", 
> headers=dict(Referer="http://www.infometeo.be/img.php?iid=1057"))
>>>> img = urlopen(r).read()
>>>> with open("tmp.jpg", "w") as f: f.write(img)
> ...
>>>>
> 
> Now if you are using that workaround a lot he may come up with more 
> sophisticated techniques. So dont ;)
> 
> Peter

Thanks Peter, it works perfectly !
At 60 fps I can even make a video ...
;-)

Olivier



More information about the Python-list mailing list