添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
满身肌肉的滑板  ·  标准版 Docker安装 ...·  3 月前    · 
谦和的番茄  ·  RSA Community·  12 月前    · 
悲伤的甜瓜  ·  AutoCAD Forum - ...·  1 年前    · 
I am trying to extract the country area from example website. And I got following errors. I am using python version 3.6
from bs4 import BeautifulSoup
url = 'http://example.webscraping.com/places/default/view/Australia-14'
html = download(url)
soup = BeautifulSoup(html)
# locate the area row
tr = soup.find(attrs={'id':'places_area_row'})
td = tr.find(attrs={'class':'w2p_fw'}) #locate the date elements
area = td.text #extract the text form the data element
print (area)
Error: "NameError: name 'download' is not defined" Just remove download,and use Requests (is what should by used anyway in the download reference).
from bs4 import BeautifulSoup
import requests
url = 'http://example.webscraping.com/places/default/view/Australia-14'
url_get = requests.get(url)
soup = BeautifulSoup(url_get.content, 'html.parser')
contry = soup.find('tr', id="places_country__row")
print(contry.text)
Output:
Country: Australia