Skip to main content

Air Spider

Project description

安装

pip install cocoman

使用

演示

do 方法

  • 参数跟 requests 的参数保持一致
  • 默认自带重试ua
  • 请求失败时,可以通过 raise_request_error 参数选择不抛出异常

发送GET请求

  • do 方法默认是 GET 请求,默认自带ua
from cocoman import Spider

s = Spider()
url = "https://www.baidu.com"
res = s.do(url)
title = res.xpath("//title/text()").get()
print(title)

发送POST请求

  • do 方法传递了 data 或者 json 参数则是 POST 请求
from pprint import pprint

from cocoman import Spider

s = Spider()

api = "https://httpbin.org/post"
form_data = {"type": "请求表单"}
res = s.do(api, data=form_data)
pprint(res.json())

json_body = {"type": "JSON请求体"}
res = s.do(api, json=json_body)
pprint(res.json())

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

cocoman-0.2.1.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file cocoman-0.2.1.tar.gz.

File metadata

  • Download URL: cocoman-0.2.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.10

File hashes

Hashes for cocoman-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a6d0f321222e6a6ed8aee86dedb559c41544b5f4919742a0c0bf3891871370e7
MD5 7d3588983c2939a778de36132ab6e536
BLAKE2b-256 ec97f86f8e3843b3f84b84bd4e3732355b09cd45e27d12b98f72386270a7aa03

See more details on using hashes here.

Supported by

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