【发布时间】:2017-11-11 04:44:48
【问题描述】:
希望从某个站点抓取城市名称。这是我迄今为止编写的相关代码,文本存储在变量中。但是,我需要将所有城市名称放在一个列表中,这似乎对我不起作用。这是 HTML:
<a id="ctl00_ContentPlaceHolder1_rptrContinents_ctl00_rptrRows_ctl00_lnkBunker" href="PortDetails.aspx?ElementID=ffd65ee0-93ea-4195-b1ba-a69c8b1908c5">Amsterdam</a>
这是我的代码: 名称 = row.find_all('th')
column_1 = col[0].string.strip()
Ifo380.append(column_1)
column_2 = col[3].string.strip()
Ifo180.append(column_2)
column_3 = col[6].string.strip()
Mdo.append(column_3)
column_4 = col[9].string.strip()
Mgo.append(column_4)
for port in names:
name= item.contents.find_all("a").string
谁能帮忙?
【问题讨论】:
-
完整的内容在哪里? column_x 是干什么用的?
标签: python beautifulsoup href screen-scraping