1

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.

enter image description here

Shrey
  • 17
  • 2

4 Answers4

2

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.stack.imgur.com/s2F9o.png'
urllib.request.urlretrieve(imagelink, './sample.png')

Reference https://docs.python.org/3/howto/urllib2.html#fetching-urls

1

Maybe this on one line?

import urllib.request

urllib.request.urlretrieve("http://searchpan.in/hacked_captcha.php?450535633", "image..jpg")
Teshtek
  • 1,212
  • 1
  • 12
  • 20
1

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")
-1

there must be .jpg or whatever extension for img the website is using u have to give the full url with extension

Extract and Download Image

Go to this link It may be helpfull.

Best of luck...

Community
  • 1
  • 1
rofelia09
  • 51
  • 11