It might be that those values are rendered dynamically i.e. the values might be populated by javascript in the page.
requests.get()
simply returns the markup received from the server without any further client-side changes so it's not fully about waiting.
You could perhaps use Selenium Chrome Webdriver to load the page URL and get the page source. (Or you can use Firefox driver).
Go to chrome://settings/help
check your current chrome version and download the driver for that version from here. Make sure to either keep the driver file in your PATH
or the same folder where your python script is.
Try this:
from bs4 import BeautifulSoup as bs
from selenium.webdriver import Chrome # pip install selenium
from selenium.webdriver.chrome.options import Options
url = "https://www.theweathernetwork.com/ca/hourly-weather-forecast/ontario/oakville"
#Make it headless i.e. run in backgroud without opening chrome window
chrome_options = Options()
chrome_options.add_argument("--headless")
# use Chrome to get page with javascript generated content
with Chrome(executable_path="./chromedriver", options=chrome_options) as browser:
browser.get(url)
page_source = browser.page_source
#Parse the final page source
soup = bs(page_source, 'html.parser')
weatherdata = soup.find('span', class_='temp')
print(weatherdata.text)
10
References:
Get page generated with Javascript in Python
selenium - chromedriver executable needs to be in PATH