【发布时间】:2013-08-15 12:25:55
【问题描述】:
所以,我基本上想做的是,找到特定页面的链接(此处为 10)。一切正常,我什至可以正确获取索引(startlink、startquote、endquote)。但是,URL 没有打印出来。为什么?而且,出了什么问题?如果你能纠正它,我会很高兴!
def web():
n=0
a=open('quora.txt', 'r') #I've saved it as a txt file in my system
b=a.read()
startlink=0
while(n<10):
startlink=b.find('<a href=', startlink+1)
startquote=b.find('"', startlink)
endquote=b.find('"', startquote)
url=b[startquote+1:endquote]
print url, startlink, startquote, endquote
n=n+1
这是我得到的输出,只有索引。不,网址
4506 4514 4514
5308 5316 5316
5357 5365 5365
5472 5480 5480
5515 5523 5523
5588 5596 5596
5639 5647 5647
5723 5731 5731
6828 6836 6836
6867 6875 6875
【问题讨论】:
标签: python python-2.7 web web-crawler