Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multithreading
#5
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)
Reply


Messages In This Thread
Multithreading - by Truman - Feb-10-2019, 01:55 AM
RE: Multithreading - by stullis - Feb-10-2019, 02:57 AM
RE: Multithreading - by scidam - Feb-10-2019, 04:42 AM
RE: Multithreading - by Truman - Feb-11-2019, 01:44 AM
RE: Multithreading - by stullis - Feb-11-2019, 04:32 AM
RE: Multithreading - by Truman - Feb-12-2019, 01:22 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020