basic.py 716 B

1234567891011121314151617181920212223242526272829303132333435
  1. import sys
  2. sys.path.append("../src/scraper/")
  3. from utils import loadBoardNames
  4. from downloadBoard import *
  5. from downloadthread import *
  6. from threadManager import ThreadManager
  7. # Load data from sqlite database
  8. v = ThreadManager("/v/")
  9. v.load()
  10. # if no data, download /v/
  11. if len(v) == 0:
  12. downloadAndSave("/v/")
  13. v.load()
  14. else:
  15. print("/v/ is already in the database")
  16. # show all saved boards in database
  17. for name in loadBoardNames():
  18. print(name)
  19. print(f"/v/ has {len(v)} posts saved")
  20. varray = v.createThreadsFromOPs()
  21. print(f"/v/ has {len(varray)} threads saved")
  22. # print all file links
  23. for link in v.getLinks():
  24. print(link)
  25. # print out all comments
  26. for post in v:
  27. print(post.getText())