You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
well the code doesn't do anything and it just shows 200,so i tried to modify the code so that the images get stored in a directory ,but still it doesn't work
``
import os
from bs4 import BeautifulSoup
import urllib.request
import requests
if response.status_code != 200:
print(f"Status: {response.status_code} — Try rerunning the code\n")
else:
print(f"Status: {response.status_code}\n")
soup = BeautifulSoup(response.content, "html.parser")
for data in soup.find_all("img", attrs={"alt":"Post image"}):
ll=data.get('src')
imagdownload=requests.get(os.path.join('https://www.reddit.com/'),ll)
img=open(os.path.join('images',os.path.basename(ll),'wb'))
for down in imagdownload.iter_content(10000):
img.write(down)
``
any idea what to do?
The text was updated successfully, but these errors were encountered:
well the code doesn't do anything and it just shows 200,so i tried to modify the code so that the images get stored in a directory ,but still it doesn't work
``
import os
from bs4 import BeautifulSoup
import urllib.request
import requests
os.makedirs('images', exist_ok=True)
url = "https://www.reddit.com/r/BabyYoda"
response = requests.get(url)
if response.status_code != 200:
print(f"Status: {response.status_code} — Try rerunning the code\n")
else:
print(f"Status: {response.status_code}\n")
soup = BeautifulSoup(response.content, "html.parser")
for data in soup.find_all("img", attrs={"alt":"Post image"}):
ll=data.get('src')
``
any idea what to do?
The text was updated successfully, but these errors were encountered: