June 2018
Beginner
508 pages
13h 8m
English
Now that the technicalities are out of the way, let's see the second section of our script (it should be at the end of the scrape.py module):
if __name__ == "__main__": parser = argparse.ArgumentParser( description='Scrape a webpage.') parser.add_argument( '-t', '--type', choices=['all', 'png', 'jpg'], default='all', help='The image type we want to scrape.') parser.add_argument( '-f', '--format', choices=['img', 'json'], default='img', help='The format images are _saved to.') parser.add_argument( 'url', help='The URL we want to scrape for images.') args = parser.parse_args() scrape(args.url, args.format, args.type)
Look at that first line; it is a very common idiom when it comes to scripting. According to the official Python ...
Read now
Unlock full access