Last active
September 2, 2019 09:36
-
-
Save JeyKJey/02af3a28cf512ee8a3096273850fe029 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
from bs4 import BeautifulSoup | |
import requests | |
page_link ='https://www.website_to_crawl.com' | |
# fetch the content from url | |
page_response = requests.get(page_link, timeout=5) | |
# parse html | |
page_content = BeautifulSoup(page_response.content, "html.parser") | |
# extract all html elements where price is stored | |
prices = page_content.find_all(class_='main_price') | |
# prices has a form: | |
#[<div class="main_price">Price: $66.68</div>, | |
# <div class="main_price">Price: $56.68</div>] | |
# you can also access the main_price class by specifying the tag of the class | |
prices = page_content.find_all('div', attrs={'class':'main_price'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks