抓取网页所有url的简单Python爬虫源码

admin 2014年5月13日09:37:44Python评论1,513 次浏览阅读模式

抓取网页所有url的简单Python爬虫源码,只用到了一个Python标准库urllib模块,没有用BeautifulSoup第三方库。

简单Python爬虫源码发,如下:

import urllib

content = urllib.urlopen('http://www.AnYun.ORG/').read()

s1=0
while s1>=0:
    begin = content.find(r'',m1)

    s1 = m2
    if(begin<=0):
        break
    elif(content[m1:m2].find(r" ")!=-1):
        m2 = content[m1:m2].find(r' ')
        url = content[m1+6:m1+m2-1]
        print url
    elif m2>=0:
        url = content[m1+6:m2-1]
        print url
print "end."

 

相关文章
weinxin
我的微信
微信扫一扫
admin
  • 本文由 发表于 2014年5月13日09:37:44
  • 转载请务必保留本文链接:https://anyun.org/a/jishuguanzhu/bianchengchalou/python/2014/0513/1082.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: