python - python3.6 aiohttp响应时间和大小
问题描述
使用 python3.6 aiohttp 有一种方法可以获取我在发出请求时使用 pycurl 获取的所有以下统计信息。
name_lookup_time = curl_handle.getinfo(pycurl.NAMELOOKUP_TIME)
connect_time = curl_handle.getinfo(pycurl.CONNECT_TIME)
app_connect_time = curl_handle.getinfo(pycurl.APPCONNECT_TIME)
pre_transfer_time = curl_handle.getinfo(pycurl.PRETRANSFER_TIME)
start_transfer_time = curl_handle.getinfo(pycurl.STARTTRANSFER_TIME)
total_time = curl_handle.getinfo(pycurl.TOTAL_TIME)
redirect_time = curl_handle.getinfo(pycurl.REDIRECT_TIME)
redirect_cnt = curl_handle.getinfo(pycurl.REDIRECT_COUNT)
total_size = curl_handle.getinfo(pycurl.SIZE_DOWNLOAD)
目前我在我的爬虫中使用 pycurl 多实现来发出请求,然后我有代码收集每个请求的详细数据。替换 pycurl 并学习新东西。我有兴趣用 aiohttp 客户端实现替换发出请求的 pycurl 多代码。
阅读 aiohttp(https://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientResponse)文档,我发现可以通过查看和计算作为 ClientResponse 对象一部分的历史序列来获得 redirect_cnt .
history
A Sequence of ClientResponse objects of preceding requests (earliest request first) if there were redirects, an empty sequence otherwise.
我可以不用大部分详细的时间数据。但是,我想收集 total_time 和 total_size 来满足我的最低要求。
解决方案
推荐阅读
- wso2 - WSO2 APIM 应用程序注册 urn:未找到批准操作
- r - 使用 textInput 选项在 R Shiny 中对数据框进行子集化
- typo3 - 我在哪里可以安全地下载旧的 TYPO3 版本?
- wso2 - WSO2 EI 6.1.1 发布请求正文未发送
- python-3.x - GraphFactory 找不到 gremlin.graph 属性配置
- vue.js - 使用 vuex-persistedstate 重定向到 fecth/asyncData 不能 100% 工作
- python - Python - 微软的 Face Api - 没有持久的人脸
- vuejs2 - Vue 动态 html - 不会解析 Vue 数据对象
- java - 如何解决循环依赖?
- javascript - CSS 未使用 BrowserSync 重新加载,并且无法使用 JS 获取 / 错误