【发布时间】:2012-05-04 16:41:35
【问题描述】:
我有一个基本循环来查找我用 urllib2.urlopen 检索到的页面上的链接,但是我试图只关注页面上的内部链接..
有什么想法可以让我的下面的循环只获取同一域上的链接吗?
for tag in soupan.findAll('a', attrs={'href': re.compile("^http://")}):
webpage = urllib2.urlopen(tag['href']).read()
print 'Deep crawl ----> ' +str(tag['href'])
try:
code-to-look-for-some-data...
except Exception, e:
print e
【问题讨论】:
标签: python web-crawler beautifulsoup