Feb-11-2019, 04:32 AM
The important part of that traceback is:
Error:requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/vows.png'
: No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/vows.png?
In downloadXKCD(), you have comicUrl = comicElem[0].get('src') print(f'Downloading image {comicUrl}') res = requests.get(comicUrl)and the traceback is indicating that comicUrl, which is passed into requests.get(), does not have a schema at the beginning. In HTML coding, it is good practice to use relative paths for URIs instead of absolute paths. As such, the beginning of the image URI is missing. You'll need to prepend "http://" to the beginning of the URI. This should work:
comicUrl = comicElem[0].get('src') print(f'Downloading image {comicUrl}') res = requests.get("http://" + comicUrl)