Reputation: 17
I am trying to extract an image from the website using python :
relevant command :
import urllib
imagelink = 'http://searchpan.in/hacked_captcha.php?450535633'
urllib.urlretrieve(imagelink, "image.jpg")
using Firefox to view image shows the following.
Upvotes: 1
Views: 209
Reputation: 7091
The image is png , all you nedd to do is save it as '.png'
Here is the code
import urllib
imagelink = 'http://searchpan.in/hacked_captcha.php?450535633'
urllib.urlretrieve(imagelink, "image.png")
Upvotes: 1
Reputation: 65
You could use the following on Python 3. You need to first do a GET request which of-course is abstracted and retrieve the content, writing it to the given filename.
import urllib.request
imagelink = 'https://i.sstatic.net/s2F9o.png'
urllib.request.urlretrieve(imagelink, './sample.png')
Reference https://docs.python.org/3/howto/urllib2.html#fetching-urls
Upvotes: 2
Reputation: 1352
Maybe this on one line?
import urllib.request
urllib.request.urlretrieve("http://searchpan.in/hacked_captcha.php?450535633", "image..jpg")
Upvotes: 1
Reputation: 51
there must be .jpg or whatever extension for img the website is using u have to give the full url with extension
Go to this link It may be helpfull.
Best of luck...
Upvotes: -1