- 新增
jsonp2json
静态方法 - 爬虫
默认保持会话
状态 - 新增
get_uuid
、base64加解密
静态方法
- 基于requests封装的一个爬虫类
- python3
from wauo import WauoSpider
spider = WauoSpider()
url = 'https://github.com/markadc'
resp = spider.send(url)
print(resp.text)
api = 'https://github.com/markadc'
data = {
'key1': 'value1',
'key2': 'value2'
}
resp = spider.send(api, data=data)
api = 'https://github.com/markadc'
json = {
'key1': 'value1',
'key2': 'value2'
}
resp = spider.send(api, json=json)
- 如果响应码不在codes范围里则抛弃响应
resp = spider.send('https://github.com/markadc', codes=[200, 301, 302])
- 如果checker返回False则抛弃响应
def is_ok(response):
html = response.text
if html.find('验证码') != -1:
return False
resp = spider.send('https://github.com/markadc', checker=is_ok)
- 实例化的时候使用default_headers参数
- 每一次请求的headers都带上cookie
spider = WauoSpider(default_headers={'Cookie': 'Your Cookies'})
resp = spider.send('https://github.com/markadc')
print(resp.request.headers)