Rohan Nayani Rohan Nayani - 10 months ago 43
Python Question

How to get image from dynamic url using urllib2?

I have generated a url from product code like,

code: 2555-525
url :

But when fetching a url, it might be a different name format on server,like

Sample code,


could we pass the url like*.png


Using wildcards in URLs is useless in most cases because

  • the interpretation of the part of the URL after is totally up to the server - so*.png might have a meaning to the server but but propably has not

  • normally (exceptions like WebDAV exist) there is no way of listing ressources in a collection or existing URLs in general apart from trying them one-by-one (which is unpractical) or scraping a known site for URLs (which might be incomplete)

For finding and downloading URLs automatically you can use a Web Crawler or Spider.