BeautifulSoup: Find Text Elements

From Glitchdata
Revision as of 18:47, 8 July 2014 by Admin (talk | contribs) (Related)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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