tester.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python3
  2. from news import News
  3. from db import db
  4. from pprint import pprint
  5. d = db()
  6. cat = 1
  7. kw = d.get_keywords(cat)
  8. f = open("links")
  9. links = f.read().split('\n')
  10. f.close()
  11. not_matched=[]
  12. matched=[]
  13. for url in links:
  14. if url == "":
  15. continue
  16. n = News(url, "57351207d47db2159a918636", "9to5", cat, kw)
  17. out = n.get()
  18. if out is not None and "weight" in out and out["weight"] > 1:
  19. matched.append(url)
  20. continue
  21. not_matched.append(url)
  22. #print("[DID NOT MATCH] %s" % url)
  23. p = {}
  24. p["kw"] = out["kw"]
  25. p["matches"] = out["matches"]
  26. p["title"] = out["title"]
  27. p["url"] = out["url"]
  28. p["weight"] = out["weight"]
  29. p["text"] = out["text"]
  30. #pprint(out)
  31. # print("#######################################")
  32. # d.insert_article(n.get())
  33. # forbesUtilCookie={'toURL':'http://www.forbes.com/sites/lizryan/2016/05/21/want-to-hire-great-people-stop-asking-stupid-interview-questions/','refURL':'','referrer':''};
  34. # Path=/; Domain=.forbes.com; Expires=Session
  35. for n in matched:
  36. print("[KEYWORD MATCH] %s" % n)
  37. for n in not_matched:
  38. print("[DID NOT MATCH] %s" % n)