B
B
Bumpy972020-05-12 17:51:17
Python
Bumpy97, 2020-05-12 17:51:17

How to download an image from a website using python?

You need a code to download a specific image from the site, BUT this is not a direct link to the image. You need to get an image from a div that is in another div, and so on.
https://rand.by/pic

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
planc, 2020-05-12
@planc

picture

5ebabe625c3c2952257218.png

click on the button and look in the network tab where and what request goes
in your case, a POST request goes with the method=getImage parameter
[email protected] ~ %  http -vv -f POST https://rand.by/ajax.php method=getImage
POST /ajax.php HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 15
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: rand.by
User-Agent: HTTPie/2.1.0

method=getImage

HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Tue, 12 May 2020 15:27:00 GMT
Server: nginx/1.10.3 (Ubuntu)
Transfer-Encoding: chunked

{
    "image": "http://farm66.static.flickr.com/65535/49887294892_1fc5852dd3_b.jpg"
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question