Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP 503 Error while using python requests module

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)
like image 313
erondem Avatar asked Jun 18 '26 19:06

erondem


1 Answers

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 Reddit's /r/learnpython subreddit

like image 55
tsadigov Avatar answered Jun 20 '26 07:06

tsadigov