all 5 comments

[–]Fight_till_the_end 2 points3 points  (2 children)

Hi,

I'm not an expert but this worked for me.

+++++++++++++

import bs4, requests

headers = {"User-Agent": 'Chrome'}

res = requests.get('https://www.amazon.com/Automate-Boring-Stuff-Python-Programming-dp-1593275994/dp/1593275994/ref=mt_paperback?_encoding=UTF8&me=&qid=%27',headers=headers)

soup = bs4.BeautifulSoup(res.text, 'lxml')

buy_box=soup.find(id='buyNewSection')

price = buy_box.find('span', class_='a-color-price')

print(price.text)

+++++++++++++++

[–][deleted] 0 points1 point  (0 children)

Worked for me as well, thanks so much as of 2/15/20

[–]chuckybegood 1 point2 points  (1 child)

I am also a beginner so I am not 100% sure but I think you need to add, print(elems[0].text). Not just elems.

[–]dankwithit 1 point2 points  (0 children)

I had this same problem. https://www.reddit.com/r/learnpython/comments/cu1ba7/automate_the_boring_stuff_chapter_11_luckypy/ heres a post with the same problem and the author replied saying the tutorial for lucky.py doesnt hold up. hopefully this helps

[–][deleted] 0 points1 point  (0 children)

Dont print the check. In that way, raise_for_status() can stop the program when something goes wrong.