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第三方库


热门话题
使用linkedList的mergesort算法无法在Java中正确实现   java SpringMVC<mvc:resources/>SpringXML模式验证?   joptionpane的java尝试捕获错误   java实时动态地将表单提交的结果输出到JSP页面   Java下一行打印。作家   java向ArrayList添加新元素会导致覆盖所有以前插入的项的属性   println Java添加的神秘输出:一些经过评估,一些经过打印   swing出现错误:无法实例化java类型。awt。事件监听器   java无限while循环,而AsyncTask未完成   java Eclipse:更改ctrl+shift的块注释样式+/   java为什么在不尝试I/O的情况下,不可能检测到TCPsocket被对等方正常关闭?   java并行流函数占用更多时间   java非泛型类型在不指定类型参数的情况下扩展泛型类型   java Spring、Hibernate和嵌入式derby Jetty自动重新部署数据库连接问题   java如何将getBooks()中生成的值(ArrayList<Book>Books变量)放入onCreate方法?   jsp Java servlet未正确重定向   如果网络可用,java从服务器获取JSON   java如何调用ArrayList中的每个数组并按年龄对ArrayList进行排序?   java线程类的静态方法和本机方法是什么