#!/usr/bin/env python
# -*- coding:utf-8 -*-
# author: Changhua Gong
import time,threading
# from urllib.request import Request, urlopen py3
# from urllib.error import URLError py3
import urllib2
#URL
req = urllib2.Request(‘http://47.93.169.69:10080/pigeon-web/user/userExtraInfo?userId=1‘)
#
rule = {0:500,1:30}
‘‘‘
Rule规则:0:50,第一次运行不睡眠即为0,直接并发50次;1:20,第二秒,相当于睡眠1秒,然后并发20次,
如第三秒需并发500次,则rule = {0:50,1:20,1:500}
‘‘‘
#Open url
def geturl():
time_b = time.time()
try:
response = urllib2.urlopen(req)
print(response.read().decode("utf-8")) # 打印输出内容
except urllib2.URLError as e:
if hasattr(e, ‘reason‘):
print(‘We failed to reach a server.‘)
print(‘Reason