Best products from r/inventwithpython

We found 4 comments on r/inventwithpython discussing the most recommended products. We ran sentiment analysis on each of these comments to determine how redditors feel about different products. We found 3 products and ranked them based on the amount of positive reactions they received. Here are the top 20.

Top comments mentioning products on r/inventwithpython:

u/TheNumberOneDuder · 1 pointr/inventwithpython

I believe the problem is not with your use of the requests.raise_for_status() method but rather with the website you've chosen. Amazon thinks you're a bot and it's not letting the request go through.

​

HTTP headers allow clients/servers to send additional information to each other when making a request/response. You can trick the server into thinking you're using the site through a browser (and that you're not a bot) if you pass HTTP headers into the request.

This should work:

import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0'}
request = requests.get("https://www.amazon.com/Automate-Boring-Stuff-Python-Programming/dp/1593275994", headers=headers)
request.raise_for_status()

I pulled the headers from the Mozilla developer docs.

The syntax of a user-agent request header is essentially <product>/<product version> <comments>. So in the user-agent header I gave you, we have Mozilla (the product)/5.0 (the version number), and then a comment (about computer specs). Then we have two other product/product version pairs: Gecko/20100101 Firefox/50.0.

​

Hope this helps :)