OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to scrape images from webistes? [duplicate]

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

Guest
I want to be able to download pictures from a site by web scraping. My site of choice is threads.net. And I watched several tutorials on how to download photos from the site, but no one was able to help me.

This is part of the code that i have written so far...

Code:
from bs4 import BeautifulSoup
import requests
import os


url = "https://threads.net"

r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser') 
images = soup.find_all('img') 
  
# for image in images: 
#     name = image['alt']
#     link = image['src']
    
#     with open(name.replace(' ', '').replace('/', '') + '.jpg', 'wb') as f:
#         im = requests.get(link)
#         f.write(im.content)


print(images)
<p>I want to be able to download pictures from a site by web scraping. My site of choice is threads.net. And I watched several tutorials on how to download photos from the site, but no one was able to help me.</p>
<p>This is part of the code that i have written so far...</p>
<pre><code>from bs4 import BeautifulSoup
import requests
import os


url = "https://threads.net"

r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
images = soup.find_all('img')

# for image in images:
# name = image['alt']
# link = image['src']

# with open(name.replace(' ', '').replace('/', '') + '.jpg', 'wb') as f:
# im = requests.get(link)
# f.write(im.content)


print(images)
</code></pre>
 

Latest posts

Top