Skip to content

Commit e62a7d1

Browse files
committed
加入三种方法爬取豌豆荚设计奖速度对比
1 parent eb8ed92 commit e62a7d1

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

.idea/workspace.xml

Lines changed: 30 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ def method_2(url):
115115
print('成功插入一组数据' + str(content))
116116

117117

118-
# if __name__ == '__main__':
119-
# start = time.time()
120-
# pool = multiprocessing.Pool(4)
121-
# pool.map(method_2, urls)
122-
# pool.close()
123-
# pool.join()
124-
# print('一共用时:' + str(time.time() - start))
118+
# if __name__ == '__main__':
119+
# start = time.time()
120+
# pool = multiprocessing.Pool(4)
121+
# pool.map(method_2, urls)
122+
# pool.close()
123+
# pool.join()
124+
# print('一共用时:' + str(time.time() - start))
125125

126126

127127
# 方式三:使用Asyncio + Aiohttp python3.4之后出的异步io模块
@@ -149,6 +149,7 @@ async def parser(url):
149149
}
150150
col.insert(content)
151151
print('成功插入一组数据' + str(content))
152+
152153
start = time.time()
153154
loop = asyncio.get_event_loop()
154155
tasks = [parser(url) for url in urls]

0 commit comments

Comments
 (0)