使用ipython笔记本编写一个scraper或spider来下载几个网页

2024-05-01 22:04:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我是新的网页刮。我们被要求使用iypthon笔记本写一个刮刀或蜘蛛下载几个网页。这是我们在课堂上学到的,但我想还有一步我想不出来。你知道吗

%pylab inline
import urllib
myUrl="http://www.google.com"
theSite=urllib.urlopen(myUrl).read()
import re
tags=re.findall('''<(.+?)>''',theSite,re.DOTALL)
print len(tags)

for i in range(100):
    print tags[]

Tags: importre网页tags笔记本urllib刮刀蜘蛛