如何用Python提取网页的某些部分

2024-07-04

目标网页:http://www.immi.gov.au/skilled/general-skilled-migration/estimated-allocation-times.htm http://www.immi.gov.au/skilled/general-skilled-migration/estimated-allocation-times.htm

我要提取的部分:

  <tr>
  <td>Skilled &ndash; Independent (Residence) subclass 885<br />online</td>
  <td>N/A</td>
  <td>N/A</td>
  <td>N/A</td>
  <td>15 May 2011</td>
  <td>N/A</td>
  </tr>

一旦代码通过搜索关键字“找到此部分”885子类
online
”,然后应该打印第五个标签内的日期,即“2011 年 5 月 15 日”如上图所示。

它只是我自己的一个监视器,用来关注我的移民申请的进展情况。


"美女——呜呜——哎呀! http://www.crummy.com/software/BeautifulSoup/

美女——呜呜——哎呀! http://www.crummy.com/software/BeautifulSoup/

晚上的 Soo-oop,

美丽,美丽的汤! http://www.crummy.com/software/BeautifulSoup/"

——刘易斯·卡罗尔,爱丽丝梦游仙境 http://www.cs.cmu.edu/%7Ergs/alice-X.html

我想这正是他的初衷吧!

假海龟可能会做这样的事情:

>>> from BeautifulSoup import BeautifulSoup
>>> import urllib2
>>> url = 'http://www.immi.gov.au/skilled/general-skilled-migration/estimated-allocation-times.htm'
>>> page = urllib2.urlopen(url)
>>> soup = BeautifulSoup(page)
>>> for row in soup.html.body.findAll('tr'):
...     data = row.findAll('td')
...     if data and 'subclass 885online' in data[0].text:
...         print data[4].text
... 
15 May 2011

但我不确定这会有帮助,因为那个日期已经过去了!

祝申请顺利!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何用Python提取网页的某些部分 的相关文章

随机推荐