概述

  • 今天, 使用python3 模拟下发包, http get 请求, 然后 采用tomorrow 多线程.

代码如下:

# coding=utf-8
from urllib import request
import json
from tomorrow import threads
import time @threads(100)
def testgetHtml(url):
requests = request.urlopen(url)
return requests start = time.time()
url = "https://www.baidu.com/"
print('begin') responses = [testgetHtml(url) for i in range(100)]
# html = [(json.loads(response.read().decode('utf-8')))['total']
html = [response.read().decode('utf-8') for response in responses]
for x in html:
print(x)

tomorrow包准备

pip install tomorrow

运行环境遇到的问题

  • 移动python目录后, pip 默认安装路径与实际项目不匹配. 现象来说就是: cd 进入项目目录后运行如上安装命令是成功的, 但是运行python程序依然找不到tomorrow包, 开始怀疑默认pip路径安装问题. 解决方法步骤如下:

    • 更改了path系统环境, 修改python 及 python\scripts 的路径, 不生效, 错误依旧.
    • 重新安装pip. 方法: pip 官网下载后, 解压.tar.gz的格式, 然后 python setup.py install 安装成功, 错误消失

其他尝试未果

  • 尝试一个方法内完成Request 和 response 读取显示.: 各种报错, 未继续.

    • 可能的原因: 涉及异步过程, 无法合理追踪, 与预期的多线程有出入.

最新文章

  1. IKONS – 赞!264 款手工打造的免费矢量图标
  2. vs2008环境nmake编译 apache 2.2.29 openssl 1.0.1g mod_ssl 不知道如何生成“"..\..\srclib\openssl\inc32\openssl\store.h"”
  3. 【leetcode】length of last word (easy)
  4. Python学习路程day8
  5. JMeter2.13进行压力测试
  6. opencv实现KNN手写数字的识别
  7. C#读取Word模板替换相应的字符串(标签)生成新的Word
  8. java检测端口号是否配占用
  9. [转]一个备份MySQL数据库的简单Shell脚本
  10. 【HDOJ】1274 展开字符串
  11. SQL Server 阻塞排除的 2 方法
  12. IntentService的使用
  13. (转)C++中返回对象的情形及RVO
  14. sencha touch视频教程
  15. Linux指令--性能监控和优化命令相关指令
  16. spring 5.1.2 mvc RequestMappingHandlerMapping 源码初始化过程
  17. eclipse中设置python的版本
  18. 《HTTP权威指南》1-HTTP概要
  19. make太慢了,加快编译速度的方法 make -j
  20. ActiveMQ(2)---ActiveMQ原理分析之消息发送

热门文章

  1. js 浏览器 宽高 各种
  2. vue教程自学笔记(二)
  3. 【阅读笔记】《C程序员 从校园到职场》第八章 算法和协议(Part 2)
  4. 基于lnmp环境安装Discuz
  5. 用matlab生成mif文件
  6. 虚拟机模拟SSD用于Ceph测试
  7. Jmeter处理返回结果的值
  8. scott用户不存在
  9. linux重启查看日志及历史记录 查询原因
  10. 使用Ajax+jQuery来实现前端收到的数据在console上显示+简单的主页设计与bootstrap插件实现图片轮播