Advertisement
asweigart

Untitled

Feb 15th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import requests, time
  2.  
  3. CONTINUE_AT = '01changer'
  4.  
  5. with open('_all-pypi-packages.txt', encoding='utf-8') as fp:
  6. packages = [i.strip() for i in fp.readlines()]
  7.  
  8. err = open('_errors.txt', 'a')
  9.  
  10. for package in packages:
  11. if CONTINUE_AT is not None and package != CONTINUE_AT:
  12. continue
  13. else:
  14. CONTINUE_AT = None
  15.  
  16. print('Downloading ' + package + '...')
  17.  
  18. response = requests.get('https://pypi.org/project/' + package)
  19. if response.status_code != requests.codes.ok:
  20. print('Error downloading package ' + package)
  21. err.write(package + '\n')
  22. continue
  23.  
  24. with open(package + '.html', 'w', encoding='utf-8') as fp:
  25. fp.write(response.text)
  26.  
  27. time.sleep(1)
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement