Issue
When I try to print response code when I request this site using requests.get
in python
no response code is showing and the program keeps running
This is my code:
import requests
print ("start")
response = requests.get("https://www.carrefouruae.com/")
print(response)
print("done")
Any explanation why this is happening and how I can fix it?
Solution
Try to specify User-Agent
HTTP header when doing the request:
import requests
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
}
response = requests.get("https://www.carrefouruae.com/", headers=headers)
print(response.text)
Prints:
<!DOCTYPE html><html dir="LTR" lang="en-AE"><head>
...
Answered By - Andrej Kesely
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.