#!/usr/bin/env python
# *-* coding:utf-8 *-*
import threading
import requests
import time # headers = {'Accept-Language': 'zh-CN,zh;q=0.9', 'Accept-Encoding': '', 'X-Forwarded-For': '192.168.66.155,192.168.66.155', 'Host': 'manage.zgg.com', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'Upgrade-Insecure-Requests': '1', 'Connection': 'close', 'Referer': 'https://manage.zgg.com/com/bg/patentlist.html?step=1&tcp=1&tc=1&isdomestic=1', 'Cache-Control': 'max-age=0', 'X-Real-Ip': '192.168.66.155', 'Cookie': '___rl__test__cookies=1543223926543; CNZZDATA1259629797=239605398-1531734016-https%253A%252F%252Fmanage.zgg.com%252F%7C1540287120; _qzja=1.772316491.1531737283599.1531792837055.1540292294391.1531792931429.1540292294391.17701204526.1.0.5.3; _qzjc=1; tmpid=e8d886fa-ddea-11e8-a6e3-000c293b4b18; NTKF_T2D_CLIENTID=guest07A3988A-AB2B-A775-F14D-D23D2CD66380; _ga=GA1.2.1366917314.1541125518; gr_user_id=486970f0-569a-49d6-9a48-c1142fac5052; grwng_uid=aa7d6f9c-d4f2-4662-9fd8-d01d6f39c0a9; OUTFOX_SEARCH_USER_ID_NCOO=1861753471.0973542; nTalk_CACHE_DATA={uid:kf_9333_ISME9754_guest07A3988A-AB2B-A7,tid:1545373456423056}; Hm_lvt_0eaa3be1a1b4ffd7be2065d4c04c3a3f=1545373457; judgeMedia=; firstLand=; _gid=GA1.2.473758069.1545623906; userName=17701204526; IsSelfReg=0; userID=160; userToken=2CF7A0A68A8F8BCBCAFC6BB684DBEC8F; gr_session_id_b34a91e0993dce4c=e58bb2a4-1b5b-432d-8406-194bb2d2f8b6; gr_session_id_b34a91e0993dce4c_e58bb2a4-1b5b-432d-8406-194bb2d2f8b6=true; Hm_lpvt_0eaa3be1a1b4ffd7be2065d4c04c3a3f=1545722251; b34a91e0993dce4c_gr_session_id=0636b46d-1247-46b5-9b0a-86b381f69174; b34a91e0993dce4c_gr_session_id_0636b46d-1247-46b5-9b0a-86b381f69174=true', 'Access-Control-Allow-Origin': '*', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'}
headers = {'Cookie': 'JSESSIONID=84A00D962C3E5977514A36AAC6F9A8AA; i18n_browser_Lang=zh-cn; JEECGINDEXSTYLE=fineui; tmpid=e8d886fa-ddea-11e8-a6e3-000c293b4b18; NTKF_T2D_CLIENTID=guest07A3988A-AB2B-A775-F14D-D23D2CD66380; _ga=GA1.2.1366917314.1541125518; gr_user_id=486970f0-569a-49d6-9a48-c1142fac5052; grwng_uid=aa7d6f9c-d4f2-4662-9fd8-d01d6f39c0a9; OUTFOX_SEARCH_USER_ID_NCOO=1861753471.0973542; nTalk_CACHE_DATA={uid:kf_9333_ISME9754_guest07A3988A-AB2B-A7,tid:1545373456423056}; Hm_lvt_0eaa3be1a1b4ffd7be2065d4c04c3a3f=1545373457; judgeMedia=; firstLand=; _gid=GA1.2.473758069.1545623906; Hm_lpvt_0eaa3be1a1b4ffd7be2065d4c04c3a3f=1545722251; Hm_lvt_098e6e84ab585bf0c2e6853604192b8b=1545732837; Hm_lpvt_098e6e84ab585bf0c2e6853604192b8b=1545732883; ZINDEXNUMBER=2000', 'Access-Control-Allow-Origin': '*', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'}
url = 'http://pc-renguoqiang:8080/crm/leadController.do?datagrid&field=id,isDuplicated,follow,followRecord,followCounts,status,intentionLevel,name,phone,mediaWechat,mediaQ,telePhone,email,lastNextContent,note,ownerId,updateName,claimTime,createDate,lastPublishDate,lastNextFollow,transferDate,company,customerUrl,postalCode,address,province,city,businessType,businessTypeInit,businessTypeIntention,dept,createName,queryName,externalSource,externalSourceKeyword,externalSourceDevice,officialFirstUrl,operationPromotionAccount,isConsult,source,initialSource,number,publicGroup,isPublic,isToken,expireTime,isDeleted,isMyself,handleStatus,version,'
def f():
start = time.time()
res = requests.get(url, headers=headers)
print res.status_code
print '{} cost {}'.format(threading.current_thread().name, time.time() - start) l = []
for i in xrange(100):
t = threading.Thread(target=f)
t.start()
l.append(t) for j in l:
j.join()
执行环境:
root@PC-RENGUOQIANG:/mnt/c/Users/RenGuoQiang/Desktop# python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
root@PC-RENGUOQIANG:/mnt/c/Users/RenGuoQiang/Desktop# python load_test.py