问题
I'm trying to make a HTTP request but the website that I currently can reach from my Firefox browser response 503 error. Code itself is really simple. After some search in the net I added user-Agent
parameter to request but it didn't help either. Can someone explain me how to get rid of this 503 error?
Btw I want to make my own alert system based on prices of btc.
import requests
url = "https://www.paribu.com"
header ={'User-Agent': 'Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0 '}
response = requests.get(url,headers = header)
print(response)
回答1:
503 means the server is overloaded: https://httpstatuses.com/503
This is not an issue with your code, it is an issue with the server you are trying to access.
回答2:
I had the same problem. Use this in your code.
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',}
r = requests.post(url, headers=headers)
r.raise_for_status()
Found from this site
来源:https://stackoverflow.com/questions/47910854/http-503-error-while-using-python-requests-module