Skip to content

Commit

Permalink
Update get_all-final.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Triwoods2333 authored Apr 16, 2024
1 parent faf5381 commit c75ea4f
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions api/get_all-final.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import requests
import sys
import time
sys.setrecursionlimit(1000000)


f = open(f'result_final.txt', 'ab')
error_index = 0
def get_latest_changes():
index = 0
global f,error_index
print("starting")
now_index = 0
try:
f = open(f'result_final.txt', 'ab')
response = requests.get('https://skimdb.npmjs.com/registry/_all_docs', stream=True, timeout=10)
response.raise_for_status()
for chunk in response.iter_content(chunk_size=8192):
index += 1
if index >= 0:
now_index += 1
print(error_index)
print(now_index)
if now_index >= error_index:
f.write(chunk)

except Exception:
print('failed index:' + str(index))
if now_index >= error_index:
error_index = now_index
print('failed index:' + str(error_index))
print('restart...')
time.sleep(10)
get_latest_changes()

get_latest_changes()
get_latest_changes()

0 comments on commit c75ea4f

Please sign in to comment.