task4.py 729 B

123456789101112131415161718192021222324252627282930313233343536
  1. """
  2. @author: luojunhui
  3. """
  4. import requests
  5. from config import accountBaseInfo
  6. from tqdm import tqdm
  7. def update_articles(gh_id):
  8. """
  9. :param gh_id:
  10. :return:
  11. """
  12. url = "http://61.48.133.26:6060/article_crawler"
  13. headers = {"Content-Type": "application/json"}
  14. body = {"ghId": gh_id}
  15. response = requests.request("POST", url=url, headers=headers, json=body)
  16. print(response.json())
  17. if __name__ == '__main__':
  18. gh_id_set = set()
  19. for key in accountBaseInfo:
  20. value = accountBaseInfo[key]['ghId']
  21. gh_id_set.add(value)
  22. for gh_id in tqdm(gh_id_set):
  23. try:
  24. update_articles(gh_id)
  25. except Exception as e:
  26. print(e)
  27. continue