初识网页urllib模块

来源【www.51dali.cn
#网络爬虫:网页蜘蛛
#网络是个只蜘蛛网,蜘蛛在网页上爬
#搜索引擎就是爬虫,爬数据,鉴定索引,建立数据库,然后排序
#爬虫代码
#问题:
#1.Python如何访问互联网 urllib模块;

url 网址

libs 网页

#Python3怎么查询网站

response = urllib.response.urlopen(’’)

html = response.read()

html = html.decode(‘utf-8’)

#print(html) 源代码
#Python实战
import urllib.request
response = urllib.request.urlopen(‘http://placekitten.com/g/200/300’)
cat_imf = response.read()
with open(‘cat_500_600.jpg’,‘wb’) as f:
f.write(cat_imf)
【java1234】

猜你喜欢

转载自blog.csdn.net/qq_21142893/article/details/82825510