python多线程

 

#!/usr/bin/python
# -*-coding:utf-8-*-
"""
@author: yugengde
@contact: yugengde@163.com
@file : Threading.py
@time: 2017/11/5 21:09
"""

import requests
from multiprocessing import Pool

urls = []
for i in range(1,21):
new_page = 'http://tieba.baidu.con/p/3522?pn=' + str(i)
urls.append(new_page)


def get_source(url):
html = requests.get(new_page)

results = Pool.map(get_source, urls)
posted @ 2017-10-31 01:22  人微言轻1  阅读(153)  评论(0编辑  收藏  举报