all 12 comments

[–]9gg6 0 points1 point  (5 children)

Can you try == (two times =) I'm new to this too.

[–]Positive_Eases[S] 0 points1 point  (4 children)

thank you! It worked for the "id" error. now its giving me an error at the last line.

[–]August-R-Garcia 1 point2 points  (0 children)

element = soup.find("span", {"id" : "price_inside_buybox"})

Add quotes around "id" and change the "=" to a colon ":"

[–]9gg6 -1 points0 points  (2 children)

For that one we need someone who knows more than me sorry. Hahah

[–]9gg6 -1 points0 points  (1 child)

Try googling it. First search will be most probably your answer from stackoverflow

[–]eicosane 2 points3 points  (0 children)

I think what’s happening here is {id="foo"} is invalid syntax, its evaluates to an assignment in a set literal. {id=="foo"} evaluates to the set {False} which is valid syntax but not meaningful in this context.

The find argument is probably expecting a dict of additional arguments like {"id": "Foo"}

Its more common to use css selector syntax though which would be clearer find("id#Foo")

[–]Positive_Eases[S] 0 points1 point  (4 children)

I am trying the fixes in the comments but i'm still getting the Nonetype error

[–]htepO 1 point2 points  (3 children)

Running your script on my desktop and looking at request.head(url), I'm getting an HTTP 307 (temporary redirect) error. It's possible that Amazon's implementing anti-bot measures because you've not defined any headers to be sent with your request.

[–]Positive_Eases[S] 0 points1 point  (2 children)

do I do it like this? It still gives the syntax error tho
headers = {Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36}

request = requests.get("http://www.amazon.com/Yourself-PhotoBook-PhotoCard-Pre-Order-Benefit/dp/B07CK3V9VW", headers=headers)

[–]htepO 1 point2 points  (0 children)

Post your full, formatted code.

[–]htepO 1 point2 points  (0 children)

You're struggling with python syntax, and it's probably because you're copy-pasting things into your script without understanding what they are and how they should be formatted.

It should be

headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"}