Mar-28-2020, 04:04 AM
I'm new to Phyton and do not have any Programming background.
I downloaded Phyton 3.8 and PYcharm. I tried to work the program below and am getting the below error
AttributeError: 'NoneType' object has no attribute 'get_text'
Looks like no values are returned by soup.find statement, how to proceed further? Thank you
I downloaded Phyton 3.8 and PYcharm. I tried to work the program below and am getting the below error
AttributeError: 'NoneType' object has no attribute 'get_text'
Looks like no values are returned by soup.find statement, how to proceed further? Thank you
import requests from bs4 import BeautifulSoup URL = 'https://www.amazon.com/Disposable-Offices-Households-Sensitive-Crowded/dp/B085TF7JPK/ref=sr_1_1?dchild=1&keywords=masks&qid=1585366634&sr=8-1' headers = {"User-Agent" : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36' } page = requests.get(URL , headers=headers) soup = BeautifulSoup(page.content, "html.parser") print(soup.prettify()) title = soup.find(id = "productTitle" ).get_text() price = soup.find(id = "priceblock_ourprice" ).get_text() print(title) print(price)