Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aclient

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aclient

发送大量异步请求

  • 1.0.7
  • PyPI
  • Socket score

Maintainers
1

aclient

安装说明

使用pip或其他 PyPi 软件包进行安装

pip install aclient

使用 aclient 发送异步请求

您可以试试:

import re
from aclient import *


aclient = AsyncClient()

# 自定义解析函数 注意; 函数必需是异步的
async def parse(response, **kwargs):

    text = await response.text()
    # 测试: 获取 title 文本 - 百度一下
    pattern = re.compile(f"<title>(.*?)</title>")
    title   = pattern.findall(text)[0]
    return title


# 请求地址 可以发送大量地址
url  = "https://www.baidu.com"

# urls列表格式
urls = [url for _ in range(2)]


result  = aclient.get(urls, custom_parse=parse)
# 打印item数据
print(result)
# 结果
# result = {'0': '百度一下', '1': '百度一下'}


# urls字典格式
urls = {
    f"第{i}个": {"url": url, "timeout": 5}
        for i in range(2)
}

result  = aclient.get(urls, custom_parse=parse)
# 打印item数据
print(result)
# 结果
# result = {'第0个': '百度一下', '第1个': '百度一下'}

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc