1
所以我有这个python代码,通过一个美味的页面运行,并从中删除了一些链接。提取方法包含一些提取所需内容的魔法。然而,运行页面一个接一个地读取相当慢 - 是否有一种方法可以在python中执行此异步操作,以便我可以同时启动多个获取请求和处理页面?Python +机械化异步任务
url= "http://www.delicious.com/search?p=varun"
page = br.open(url)
html = page.read()
soup = BeautifulSoup(html)
extract(soup)
count=1
#Follows regexp match onto consecutive pages
while soup.find ('a', attrs={'class': 'pn next'}):
print "yay"
print count
endOfPage = "false"
try :
page3 = br.follow_link(text_regex="Next")
html3 = page3.read()
soup3 = BeautifulSoup(html3)
extract(soup3)
except:
print "End of Pages"
endOfPage = "true"
if valval == "true":
break
count = count +1
看看“线程”和“多处理”。 – katrielalex 2010-12-19 00:56:41
是否有任何特别的框架可以很好地与机械化和BeautifulSoup配合使用? – varunsrin 2010-12-19 02:15:34