[Python] Invalid Schema: No connection adapters were found for [Image URL]

The text is quite messy as it is written in my own memo.

python.py


import requests as req

#First of all, from the point of acquiring one image
test_url="https://papimo.jp/h/00031715/hit/view/605"
soup = BeautifulSoup(html, "html.parser")

img_url=[]
img_tags=soup.find("table",attrs={"class":"graph-some"}).find_all("img")[-1]
img_tag=img_tags.get("src")
img_url.append(img_tag)

reqData1 = req.get(img_url)
with open('/content/gdrive/MyDrive/Colab Notebooks/iland_img/605.png', 'wb') as file:
  file.write(reqData1.content)

I just wanted to download one for testing, so I thought I didn't need to use a for statement. When I actually run it

python.py


InvalidSchema: No connection adapters were found for[Image URL]

Error occurs. The problem was that I just passed the list to req.get. If you turn it with a for statement normally, it will be solved

python.py


import requests as req

#First of all, from the point of acquiring one image
test_url="https://papimo.jp/h/00031715/hit/view/605"
soup = BeautifulSoup(html, "html.parser")

img_url=[]
img_tags=soup.find("table",attrs={"class":"graph-some"}).find_all("img")[-1]
img_tag=img_tags.get("src")
img_url.append(img_tag)

for i_url in img_url:
  reqData1 = req.get(i_url)
  with open('/content/gdrive/MyDrive/Colab Notebooks/iland_img/605.png', 'wb') as file:
      file.write(reqData1.content)

Recommended Posts

[Python] Invalid Schema: No connection adapters were found for [Image URL]
Personal notes for python image processing
Recommended container image for Python applications
[boost :: python] TypeError: No to_python (by-value) converter found for C ++ type: boost :: shared_ptr <...>
What to do if No Python documentation found for ... appears in pydoc