【问题标题】:get the data from html frames从 html 框架中获取数据
【发布时间】:2014-02-14 03:04:00
【问题描述】:

我尝试在this html 框架中获取表格信息。我的意思是有列的表:

Year,Month,Oil Production m3,Gas Production Ksm3,...

使用beautifulSoup,这是迄今为止我尝试过的:

from bs4 import BeautifulSoup
from urllib import urlopen, urlretrieve, quote

url_base = 'https://www.og.decc.gov.uk/information/wells/pprs/Well_production_onshore_oil_fields/onshore_oil_fields_by_well/onshore_oil_fields_by_wel.html'
u = urlopen(url_base)
html = u.read().decode('utf-8')
u.close()
soup = BeautifulSoup(html)

但这仅检索主页信息,而不是页面框架。 当我通过框架链接更改 url base 时,它​​告诉我请求的页面已过时。

【问题讨论】:

  • 请更清楚地解释您的问题,因为当我加载页面时,我会在侧边栏菜单中看到所有页面,而您只需单击或引用它的 url

标签: python beautifulsoup screen-scraping html-frames


【解决方案1】:

我认为您复制了错误的网址。当我使用以下内容时,它起作用了。

url_base = 'https://www.og.decc.gov.uk/information/wells/pprs/Well_production_onshore_oil_fields/onshore_oil_fields_by_well/0.htm'

注意:是.../onshore_oil_fields_by_well/0.htm

而不是.../onshore_oil_fields_by_well/0.html

【讨论】:

  • 我的错!谢谢!我想我得去咖啡机了!
猜你喜欢
  • 1970-01-01
  • 2018-06-22
  • 2018-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-23
  • 1970-01-01
相关资源
最近更新 更多