0
我正在编写一个脚本,每天都会在网页上打开最新的文件。到目前为止我的代码如下:需要每天用Python打开最新的PDF文件2.7
from BeautifulSoup import BeautifulSoup
import urllib2
import re
html_page = urllib2.urlopen("http://www.baytown.org/city-hall/departments/police/daily-media-report")
soup = BeautifulSoup(html_page)
for link in soup.findAll('a', attrs={'href':
re.compile("^/home/showdocument")}):
print link.get('href')
我的输出
/home/showdocument?id=7455
/home/showdocument?id=7379
/home/showdocument?id=7381
/home/showdocument?id=7385
/home/showdocument?id=7385
/home/showdocument?id=7401
/home/showdocument?id=7451
/home/showdocument?id=7453
我需要阅读该列表中的最新的文件(最高ID#)和Im卡住。我如何找到具有最高编号的文件并读取它?
这是它。谢谢 – Rod