python中的异步请求。

simple-requests的Python项目详细描述


简单的请求允许您获得异步的性能优势 请求,而不需要使用任何异步编码范式。

用法

fromsimple_requestsimportRequests# Creates a session and thread poolrequests=Requests()# Sends one simple request; the response is returned synchronously.login_response=requests.one('http://cat-videos.net/login?user=fanatic&password=c4tl0v3r')# Cookies are maintained in this instance of Requests, so subsequent requests# will still be logged-in.profile_urls=['http://cat-videos.net/profile/mookie','http://cat-videos.net/profile/kenneth','http://cat-videos.net/profile/itchy']# Asynchronously send all the requests for profile pagesforprofile_responseinrequests.swarm(profile_urls):# Asynchronously send requests for each link found on the profile pages# These requests take precedence over those in the outer loop to minimize overall waiting# Order doesn't matter this time either, so turn that off for a performance gainforfriends_responseinrequests.swarm(profile_response.links,maintainOrder=False):# Do something intelligent with the responses, like using# regex to parse the HTML (see http://stackoverflow.com/a/1732454)friends_response.html

发布历史记录

1.1.1(2014年6月27日)

api更改
  • bundleParam参数添加到Requests.oneRequests.swarmRequests.each

1.1.0(2014年5月1日)

api更改
  • defaultTimeout参数已添加到Requests.__init__
错误修复
    退出时没有错误/警告
  • 由于gevent 1.0中的api更改而进行的修复
  • 修复了几个文档错误
功能
  • 添加了一个patch类,其中包含urllib3的monkey补丁(以减少 立即打开连接/文件)和httplib(忽略错误报告内容长度的服务器)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
WebLogic10.3JAR包含Weblogic的java。马绍尔群岛共和国。远程异常   JavaHibernate不更新或删除,但插入   java检查字段是否被覆盖   java程序只发送一次消息   使用DefaultDesktopManager对JInternalFrame进行图标化时出现java异常   如何在firebase数据库安卓 studio/java中检索特定子级的数据?   java JsonIllegalstateexception:应为BEGIN_数组,但在第1行第61列为字符串。$顾客数据   javascript在使用Angular JS调用HTML文件中的函数时遇到问题   在Java中填充多维数组   java selenium webdriverXpath不适用于列表   在不同bean上运行事务的java抛出异常   java我可以知道backoffice用户是否忘记保存其更改吗?   数学算术运算   java如何格式化和比较来自bash/vm的输入?   关闭JDBC连接时出现java问题   java错误:无法解析MyFirstApp教程中的符号“edit_message”   java将/n替换为带返回码的真正utf8