Skip to content Skip to sidebar Skip to footer

Using Python's Beautifiulsoup Library To Parse Info In A Span Html Tag

I am writing a Python web scraper that grabs the price of a certain stock. At the end of my program, there are a few print statements to correctly parse the html data so I can grab

Solution 1:

You can use .find with .text function to get your required value.

Ex:

from bs4 importBeautifulSouppage_soup= BeautifulSoup(html, "lxml")
price = page_soup.find("span",{"id":"quote_val"}).text
print( price )

Output:

0.0008

Post a Comment for "Using Python's Beautifiulsoup Library To Parse Info In A Span Html Tag"