client_detection.py 820 B

12345678910111213141516171819202122232425262728293031323334
  1. import requests
  2. import json
  3. class ClientDetection:
  4. def __init__(self, base_url):
  5. self.base_url = base_url
  6. def list_detect_list(self):
  7. response = requests.get(f'{self.base_url}/')
  8. return response.json()
  9. def add_live(self, data):
  10. headers = {'Content-Type': 'application/json'}
  11. response = requests.post(f'{self.base_url}/', data=json.dumps(data), headers=headers)
  12. return response.json()
  13. def main():
  14. # 使用示例
  15. client = ClientDetection('http://127.0.0.1:9081')
  16. print(client.list_detect_list())
  17. data = [
  18. {
  19. "str": "https://live.bilibili.com/14917277",
  20. },
  21. {
  22. "str": "https://live.bilibili.com/14917277",
  23. }
  24. ]
  25. print(client.add_live(data))
  26. if __name__ == "__main__":
  27. main()