用户:
ZCH快乐哈哩查看:0 回复:0 评论:0 创建时间:2020-09-07T19:55:31
【作品展示】

【作品介绍】
……
【作品源代码】
from urllib import request
import json
import time
import threading
url = "https://api.codemao.cn/web/forums/posts/58388145/details?offset=1&limit=10"
user_agent = "Mozilla/5.0 (Windows NT 6.2; WOW喵) AppleWebKit/537.36 (KHML, like Gecko) Chrome/27.0.1453.94 Safari/537.36"
head = {}
head["User-Agent"] = user_agent
def blaster(thread_i):
for i in range(0, 15):
req = request.Request(url, headers=head)
response = request.urlopen(req)
data = response.read().decode('utf-8')
j = json.loads(data)
print("\033[36m[ThreadId: {}]\033[30m ".format(
threading.currentThread().ident) + str(j['n_views']))
time.sleep(0.1)
t = [None for x in range(1000000)]
for i in range(1, 1000):
t[i] = threading.Thread(target=blaster, args=[str(i)])
t[i].start()
if __name__ == '__main__':
try:
while 1:
pass
except KeyboardInterrupt:
pass
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn