当前位置: 移动技术网 > IT编程>脚本编程>Python > python抓取百度首页

python抓取百度首页

2019年04月05日  | 移动技术网IT编程  | 我要评论

人体结构素描,阳泉区号,忆豆香

import urllib
def downurl(url,filename):
    try:
        fp=urllib.urlopen(url)
    except:
        print('download error')
        return 0
    op=open(filename,'wb')
    while 1:
         s=fp.read()
         if not s:
             break
         op.write(s)
    fp.close()
    op.close()
    return 1
downurl("https://www.baidu.com","d:\\code\\url.txt")

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网