BeautifulSoup: Find Text Elements

From Glitchdata
Jump to navigation Jump to search
  • Using soup.find_all

Example

import urllib.request
from bs4 import BeautifulSoup

# open the webpage and assign the content to a new variable
base = urllib.request.urlopen('http://www.weather.com/weather/today/Beijing+CHXX0008:1:CH')
f = base.readlines()
f = str(f)

soup = BeautifulSoup(f)
rn_base = soup.find_all(itemprop="temperature-fahrenheit")


Links


Related