012-autoadder.py 859 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import pathlib
  2. current = pathlib.Path(__file__).parent
  3. root = current.parent
  4. import sys
  5. sys.path.append(str(root))
  6. import assets
  7. """ Make sure You have API key and CX in config file. """
  8. """ https://programmablesearchengine.google.com/ """
  9. location = root / pathlib.Path("config.json")
  10. resources = assets.config_loader(assets.app_config).load(location).resources
  11. autoadder = resources.autoadder
  12. print("Questing 5907608646584...")
  13. print(autoadder.find("5907608646584"))
  14. print()
  15. print("Testing app:")
  16. factory = assets.user_factory()
  17. factory.nick = "sample"
  18. factory.password = "password"
  19. user = factory.result
  20. collection = assets.users_collection()
  21. collection.add(user)
  22. app = assets.autoadder_app(collection, resources.autoadder)
  23. print("Questing 5907608646584...")
  24. print(app.find({
  25. "apikey": user.apikey,
  26. "barcode": "5907608646584"
  27. }))
  28. print()