本文整理汇总了Python中threadPool.ThreadPool.wait_completion方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadPool.wait_completion方法的具体用法?Python ThreadPool.wait_completion怎么用?Python ThreadPool.wait_completion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threadPool.ThreadPool
的用法示例。
在下文中一共展示了ThreadPool.wait_completion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from threadPool import ThreadPool [as 别名]
# 或者: from threadPool.ThreadPool import wait_completion [as 别名]
print("check the robot,----------------" + str(resp))
soup = BeautifulSoup(content, "html.parser")
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Cookie"] = resp["set-cookie"]
headers["Referer"] = "http://jandan.net/block.php?from=" + path
data = {
"hash": soup.find("input", attrs={"name": "hash"})["value"],
"from": soup.find("input", attrs={"name": "from"})["value"],
}
append = soup.find("form", attrs={"method": "post"})["action"]
nextPath = "http://jandan.net/block.php" + append
resp, content = h.request(nextPath, method="POST", headers=headers, body=urlencode(data))
if resp.status == 302:
return getUrls(resp["location"])
else:
return []
if __name__ == "__main__":
pool = ThreadPool(5)
for index in range(1665, 1680):
urls = getUrls("http://www.jandan.net/ooxx/page-%d#comments" % (index))
savepath = "/home/xu/Pictures/" + str(index)
if not os.path.exists(savepath):
os.makedirs(savepath)
for url in urls:
pool.add_task(query_save, url, savepath)
pool.wait_completion()
print("process successed")