Skip to main content

爬虫者的贴心助手

Project description

更新历史

  • 新增jsonp2json静态方法
  • 爬虫默认保持会话状态
  • 新增get_uuidbase64加解密静态方法
  • 删除download_textdownload_bdata,合并为download
  • 新增update_default_headers方法
  • make_md5支持字符串二进制参数,并且可以加盐
  • send方法加入delay参数,请求时可以设置延迟
  • 新增tools包、spiders
  • 线程池管理者加入上下文,可以使用with
  • 新增get_results方法,获取所有fs的返回值
  • 可以提前在send方法之前自定义延迟、超时
  • 线程池管理者新增running方法,可以用于判断任务状态
  • send方法加入详细注释

项目说明

  • 基于requests封装的一个爬虫类

Python解释器

  • python3.10+

如何使用?

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


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.6.4.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file wauo-0.6.4.tar.gz.

File metadata

  • Download URL: wauo-0.6.4.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for wauo-0.6.4.tar.gz
Algorithm Hash digest
SHA256 6b373744814f173eaaa09ef002f15cee481a4b1a87360abbdc0679a7867350e8
MD5 dedaf2f00201dafd7489a60346e25698
BLAKE2b-256 4bbb82074d12d6900f3b27b57b1ae06dafe1cb6147ce33976bfad2e17f2c165b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page