task4.py 641 B

1234567891011121314151617181920212223242526272829303132
  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://192.168.100.31:6062/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. update_articles(gh_id)