Created
April 21, 2020 08:22
-
-
Save BMU-Verlag/478215c6f9bc92c2113561574f26dbfb to your computer and use it in GitHub Desktop.
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(url): | |
page = requests.get(URL, headers=HEADERS) | |
soup = BeautifulSoup(page.content, 'html5lib') | |
title_span = soup.find('span', id='productTitle') | |
name = '' | |
if title_span is not None: | |
name = title_span.get_text().strip() | |
price = 0.0 | |
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: | |
price = parse_price(price_span.get_text()) | |
return { 'name': name, 'price': price } | |
if __name__ == '__main__ ': | |
result = get_article_details(URL) | |
if price <= TARGET_PRICE: | |
send_email(result['name'], result['price']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment