2.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. '''
  2. Created on 2019年8月6日
  3. @author: User
  4. '''
  5. from BiddingKG.dl.common.Utils import save,load
  6. import requests
  7. import json
  8. import redis
  9. import BiddingKG.dl.interface.settings as settings
  10. # 连接redis数据库
  11. db = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT,
  12. db=6,password=settings.REDIS_PASS)
  13. def test(name,content):
  14. user = {
  15. "content": content,
  16. "id":name
  17. }
  18. myheaders = {'Content-Type': 'application/json'}
  19. _resp = requests.post("http://192.168.2.101:15015" + '/article_extract', json=user, headers=myheaders, verify=True)
  20. resp_json = _resp.content.decode("utf-8")
  21. print(resp_json)
  22. return resp_json
  23. if __name__=="__main__":
  24. queue = load("err.pk")
  25. print(queue)
  26. data = json.loads(queue[1].decode())
  27. _data = data["content"]
  28. print(_data)
  29. test("12",_data)
  30. '''
  31. print(2)
  32. while(True):
  33. queue = db.blpop(settings.ERROR_QUEUE)
  34. if queue:
  35. print(3)
  36. break
  37. save(queue,"err.pk")
  38. '''