Last active
February 21, 2024 11:35
-
-
Save jrivero/1407342 to your computer and use it in GitHub Desktop.
OptionParser boilerplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __name__ == '__main__': | |
| parser = OptionParser() | |
| options_a = [ | |
| ["-s", "--spiders", dict(dest="spiders", type="int", default=1, help="sends more than one spider")], | |
| ["-S", "--nospinner", dict(dest="spinner", action="store_false", default=True, help="turns off the spinner")], | |
| ["-v", "--verbose", dict(dest="verbose", action="store_true", default=False, help="outputs every request (implies --nospiner)")], | |
| ["-d", "--depth", dict(dest="depth", type="int", default=-1, help="does a breadth-first crawl, stopping after DEPTH levels (implies --breadth)")], | |
| ["-b", "--breadth", dict(dest="breadth", action="store_true", default=False, help="does a breadth-first crawl; may be used with --depth")], | |
| ] | |
| for s, l, k in options_a: | |
| parser.add_option(s, l, **k) | |
| (options, args) = parser.parse_args() | |
| test(options, args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment