爬虫者的贴心助手
Project description
项目说明
- 基于requests封装的一个爬虫类
Python解释器
- python3
如何使用?
from wauo import WauoSpider
spider = WauoSpider()
GET
url = 'https://github.com/markadc'
resp = spider.send(url)
print(resp.text)
POST
使用data参数
api = 'https://github.com/markadc'
data = {
'key1': 'value1',
'key2': 'value2'
}
resp = spider.send(api, data=data)
使用json参数
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)
为headers增加默认字段
- 实例化的时候使用default_headers参数
例子1
- 每一次请求的headers都带上cookie
spider = WauoSpider(default_headers={'Cookie': 'Your Cookies'})
resp = spider.send('https://github.com/markadc')
print(resp.request.headers)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wauo-0.5.1.tar.gz
(4.3 kB
view details)
File details
Details for the file wauo-0.5.1.tar.gz
.
File metadata
- Download URL: wauo-0.5.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a42c91a1f401be41dbf64c47bcec5547849df1824a9f23a9be7095a6dd3aa56e |
|
MD5 | cbb92f6b1fbed1c6735cb162cc529bde |
|
BLAKE2b-256 | 34b7c41871a58e0f8345fef5771b7a954a26e80d95fef1d2d007437052199d18 |