| 1234567891011121314151617181920212223242526272829 |
- # -*- coding: UTF-8 -*-
- import requests
- # url = 'https://doutula.com/photo/list/'
- url = "http://baidu.com"
- r = requests.get(url)
- # 获取 响应状态码
- print(r.status_code)
- # 拿到二进制的内容
- print(r.content)
- # 得到字符串的内容
- ## 方式1:
- # 我们自己指定一个字符编码进行解码
- print(r.content,enconding='utf-8')
- ## 方式2:
- # 使用系统默认的字符编码进行解码
- html = r.text
- print(html)
- #=======================爬取图片=========================#
-
- r = requests.get(url="http://img.doutula.com/production/uploads/image/2020/06/09/20200609705266_afoUFD.png")
- with open("./wangjingze.png", 'wb') as f:
- f.write(r.content)
|