Now, let's start writing the script. I'll go through the source in three steps: imports, arguments parsing, and business logic.
First approach – scripting
The imports
Here's how the script starts:
# scrape.py
import argparse
import base64
import json
import os
from bs4 import BeautifulSoup
import requests
Going through them from the top, you can see that we'll need to parse the arguments, which we'll feed to the script itself (argparse). We will need the base64 library to save the images within a JSON file (json), and we'll need to open files for writing (os). Finally, we'll need BeautifulSoup for scraping the web page easily, and requests to fetch its content. I assume you're familiar...