requests 爬虫入门

#!/usr/bin/env python
# coding=utf-8
"""
@author : 虫子慢慢爬

"""
import requests

url = 'http://www.baidu.com' # 定义要爬取url的
response = requests.get(url) #通过requests获取访问百度的响应体

print(response.status_code)#打印响应体的code码
print (response.text) #打印响应的html
# print (response.json) 如果返回的是json形式字符创  可以转化为json
print(response.headers)#打印响头
print(response.cookies)#打印 cookies

猜你喜欢

转载自www.cnblogs.com/bianzhiwei/p/9187546.html