不死孤狼
IT 从来都是一个有新技术驱动的行业
#!usr/bin/python
# -*- coding: utf-8 -*-
# @Time : 2018/5/1 8:36
# @Author : 黑咖啡
# @Email : webaa88@126.com
# @File : webtest.py
# @Software: PyCharm

import requests
import json
import time
import threading

# count = 20000
# i=1
#
# while i < count:
# url = 'http://192.168.1.105'
# try:
# response = requests.get(url,)
# response.encoding='utf-8'
# except Exception as e:
# print(e)
# i += 1
# print(type(response.status_code))
# print(time.localtime())
# # print(json.dumps(response.text))
# if response.status_code != 200:
# count -= 1000
# print(count)
# print('errr!')
# else:
# print('loop: %s'%i)
# # print(response.text)
# print(response.status_code)
# # print(json.dumps(response.text))



def gettest(url,count):
i = 1
error = 0
while i < count:
try:
ret = requests.get(url)
except Exception as e:
print(e)
print('server有点扛不住了,让他休息一下吧!一会在干他!')
error += 1
time.sleep(3)
pass
#return
ret.encoding='utf-8'
print(ret.status_code)
print(json.dumps(ret.text))
print('loop: %s'%i)
print('错误册数:%s'%error)
i += 1
if __name__ == '__main__':
count = 1000

for i in range(5):
print(i)
t = 't%s'%i
print(t)
t = threading.Thread(target=gettest, args=('http://192.168.1.105',count))
t.start()

# t1 = threading.Thread(target=gettest, args=('http://192.168.1.105',count))
# t2 = threading.Thread(target=gettest, args=('http://192.168.1.105',count))
# t1.start()
# t2.start()
posted on 2018-05-01 18:11  不死孤狼  阅读(115)  评论(0)    收藏  举报