Reputation: 49
This code prints only:
send: b'GET /images/cms/thumbs/818029804609cbb6501795d736843e86c5e0051b/yacshik_orange_flowersbay1_370_370.jpg HTTP/1.1
Host: flowersbay.ru
User-Agent: python-requests/2.18.4
Accept: /
Accept-Encoding: gzip, deflate
Connection: keep-alive
import requests
import logging
try:
import http.client as http_client
except ImportError:
# Python 2
import httplib as http_client
http_client.HTTPConnection.debuglevel = 1
# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
url = "https://flowersbay.ru/images/cms/thumbs/818029804609cbb6501795d736843e86c5e0051b/yacshik_orange_flowersbay1_370_370.jpg"
requests.get(url, verify=False, stream=True)
And then noting happens, even if I'm waiting really long time. Other requests, e.g. https://de.fishki.net/picsw/062009/26/toys/014.jpg -- respond fast.
Could you, please, help me to find a reason of such behavior?
Upvotes: 0
Views: 7911
Reputation: 260
Well apparently the website you're trying to request is blocking the python agent for http requests. You need to fake a browser in the headers of your request, something like this
url = "https://flowersbay.ru/images/cms/thumb/818029804609cbb6501795d736843e86c5e0051b/yacshik_orange_flowersbay1_370_370.jpg"
header = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
response = requests.get(url,headers=header)
This should return an 200 OK status.
Upvotes: 2