3 Star 4 Fork 1

jeffyan20i00/反刷Star记录器

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tracingSpider.py 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
jeffyan20i00 提交于 2020-08-07 13:17 . added id
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jeffyan2000/star_recorder.git
git@gitee.com:jeffyan2000/star_recorder.git
jeffyan2000
star_recorder
反刷Star记录器
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385