Hello everyone!
I would like to thank you in advance for looking at my thread, and trying to resolve my issue.
What I'm trying to achieve, is to scrape the current value of gold (in ounces) from a website. However, my code pulls the data correctly, but it displays the HTML tags in the printed results.
I've spent countless hours Googling to try and fix this, but I cannot resolve it. You guys are my only hope haha!
Here's my code I'm using to scrape with:
Thanks again!
I would like to thank you in advance for looking at my thread, and trying to resolve my issue.
What I'm trying to achieve, is to scrape the current value of gold (in ounces) from a website. However, my code pulls the data correctly, but it displays the HTML tags in the printed results.
I've spent countless hours Googling to try and fix this, but I cannot resolve it. You guys are my only hope haha!
Here's my code I'm using to scrape with:
#imports required modules import requests from bs4 import BeautifulSoup #requests html page to parse page = requests.get("https://www.bullionbypost.co.uk/") #parses page and stores it in the 'soup' variable soup = BeautifulSoup(page.content, 'html.parser') #searches for tags in the HTML results = soup.find_all("span", {"class": "gold-price-per-ounce"}) #prints results from the executed code above print(results)This is what the program returns:
Output:[<span class="gold-price-per-ounce">£1468.80</span>]
Like I mentioned earlier, the desired results would be to print the text string containing the value of gold (without the HTML tags).Thanks again!
Larz60+ write Nov-02-2020, 08:08 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
I added for you this time. Please use bbcode tags on future posts. Thank you.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
I added for you this time. Please use bbcode tags on future posts. Thank you.