2014-01-23 38 views
-1

我试图获取this html框架中的表格信息。我的意思是有列的表:从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) 

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

+0

请解释更清楚什么是你的问题,因为当我加载页面我看到在工具栏菜单中的所有页面,只是你ahve点击或引用它的网址 –

+0

@ Vkt0r我不理解您的评论。请阅读下面的答案! – agstudy

回答

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

+0

我的不好!谢谢!我想我必须去咖啡机! – agstudy

+0

@agstudy我在开始时也犯了同样的错误。 :) – Ray