Skip to content

Instantly share code, notes, and snippets.

@jrivero
Last active February 21, 2024 11:35
Show Gist options
  • Save jrivero/1407342 to your computer and use it in GitHub Desktop.
Save jrivero/1407342 to your computer and use it in GitHub Desktop.
OptionParser boilerplate
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