This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_article_details(article): | |
url = article['url'] | |
article['price'] = 0.0 | |
article['name'] = '' | |
if url is not None: | |
page = requests.get(url, headers=HEADERS) | |
soup = BeautifulSoup(page.content, 'html5lib') | |
title_span = soup.find('span', id='productTitle') | |
if title_span is not None: | |
article['name'] = title_span.get_text().strip() | |
price_span = soup.find('span', id='priceblock_dealprice') | |
if price_span is None: | |
price_span = soup.find('span', id='priceblock_ourprice') | |
if price_span is None: | |
price_span = soup.find('span', class_=a-color-price') | |
if price_span is not None: | |
article['price'] = parse_price(price_span.get_text()) | |
return article |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment