代码拉取完成,页面将自动刷新
import requests
import utils
import threading
import time
# Load Url_file
url_file = open("url_list.txt", 'r')
urls = url_file.readlines()
# ex: 'jeffyan2000/Adapted-game-snake'
def get_star(url, id):
req = requests.get(url="https://gitee.com/" + url)
found = req.text.find("stargazers")
current = found + len("stargazers")
res = -1
if found >= 0:
res = ""
while req.text[current] != '>':
if req.text[current] in "0123456789":
res += req.text[current]
current += 1
result_list[id] = int(res)
if __name__ == '__main__':
result_list = [-1 for _ in range(len(urls))]
threads = []
s = time.time()
for i, url in enumerate(urls):
while url.endswith('\n'):
url = url[:-1]
t = threading.Thread(target=get_star, args=(url, i))
threads.append(t)
t.start()
for thread in threads:
thread.join()
print(result_list)
print("took " + str(time.time() - s) + " seconds")
utils.is_result_file_exist(urls) # check file before adding new result
utils.result_add_to_file(result_list) # add new result and save file
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。