【发布时间】:2018-06-06 16:39:20
【问题描述】:
我正在寻找使用 BeautifulSoup 刮掉 a-href 中的标题。 实际上,我的代码运行不正常。
import requests
from bs4 import BeautifulSoup
name = 'Flow'
namec = 'Flow'
url = 'http://warframe.wikia.com/wiki/' + name
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
main_text = soup.find('div', class_='mw-content-ltr mw-content-text')
ada = main_text.find_all('a', title=True)
页面是http://warframe.wikia.com/wiki/Flow
我需要像这样从 div 类 pi-data-value pi-font 中提取数据:
Missions:
Survival (DS3, T3)
Excavation (T3)
Enemies:
Arid Butcher 0.03%
Bailiff 0.03%
Bailiff Defector 0.03%
Butcher 0.03%
Drahk Master 0.03%
Drekar Manic 0.03%
Frontier Bailiff 0.03%
Frontier Butcher 0.03%
Grineer Manic 0.22%
Hyekka Master 0.03%
Infested Chroma 0.6%
Infested Mesa 0.6%
Kuva Butcher 0.03%
Kuva Drahk Master 0.03%
Kuva Hyekka Master 0.03%
Tenno Specter 0.6%
Tusk Butcher 0.03%
Other:
Orokin Tower Containers
【问题讨论】:
-
试试
main_text = soup.find('div', {'class': 'mw-content-ltr mw-content-text'})
标签: python beautifulsoup