I am learning web scraping using Beautiful Soup and Python. I thought a good first step would be to simply extract the temperature from a website. I have followed a tutorial which taught me to access text from a job posting website. However, while trying to extract the temperature from the weather network website I cannot return the temperature value to the console.
Here is my code,
import requests
from bs4 import BeautifulSoup
url = 'https://www.theweathernetwork.com/us/weather/new-york/new-york'
data = requests.get(url).text
soup = BeautifulSoup(data, 'lxml')
temp = soup.find('span', class_ = "temp").text
print(temp)
when I add the ".text" to the temp variable the code complete but the print is blank.
when I remove the ".text" from the temp variable I get the desired spot in the HTML code but without the integer, like this <span class="temp"></span>
Any help is much appreciated! Thanks!