spacepaste

  1.  
  2. #!/usr/bin/python
  3. import csv
  4. import json
  5. import argparse
  6. import requests
  7. from datetime import datetime
  8. from dateutil import parser
  9. arg_parser = argparse.ArgumentParser(description="Check all the active forms of this site")
  10. arg_parser.add_argument("-u", "--url", dest="url", default="https://www.entersite.com",
  11. help="URL of main website")
  12. arg_parser.add_argument("-d", "--date", dest="changedate", default="1970-01-01",
  13. help="Only check for files changed after this date (YYYY-MM-DD)")
  14. arg_parser.add_argument("-o", "--output", dest="storagefile", default="output.csv",
  15. help="File to store output")
  16. arg_parser.add_argument("-c", "--cookie", dest="cookie_credential", default='some_random_cookie_value_here',
  17. help="AOS cookie value of logged in user")
  18. args = arg_parser.parse_args()
  19. # Setting cookie parameter
  20. # GETTING ERROR MESSAGE TypeError: 'Namespace' object is not subscriptable on next line.
  21. cookie_var = {'AOS': args['cookie_credential']}
  22. # Setting change date parameter
  23. starting_date = datetime.date(args['changedate'].split("-"))
  24. # Tweaking base URL
  25. if not str(args['url']).startswith("http"):
  26. args['url'] = "https://" + args['url']
  27. base_url = str(args['url']).rstrip("/")
  28. TRACEBACK
  29. ----------
  30. Traceback (most recent call last):
  31. File "/Users/jurgengaeremyn/git/Tooling/Python/scraping-antwerpen.be/antwerpen_check_forms.py", line 22, in <module>
  32. cookie_var = {'AOS': args['cookie_credential']}
  33. TypeError: 'Namespace' object is not subscriptable
  34.