python爬虫入门(1)

第一个爬虫

爬取百度页面

import urllib.request
response=urllib.request.urlopen("http://baidu.com/")
html=response.read()
print(html)

爬取煎蛋网妹子图

import urllib.request

response =urllib.request.urlopen('http://wx3.sinaimg.cn/mw600/0072bW0Xly1fonc54ncwmj30m80xcgtn.jpg')
#把地址转化为request对象
cat_img=response.read()

with open('D:\python\myspoils\cat_09.jpg','wb') as f:
    f.write(cat_img)

猜你喜欢

转载自blog.csdn.net/qq_16546829/article/details/79342885