I have written a small piece of code to download images from Instagram. Here is the code:
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as req
import urllib.request as reqq
from selenium import webdriver
import os
browser = webdriver.Chrome("D:\\Python_Files\\Programs\\chromedriver.exe")
url = "https://www.instagram.com/p/CFRY7X2AnOx/"
browser.get(url)
image_url = browser.find_element_by_class_name('KL4Bh').find_element_by_tag_name('img').get_attribute('src')
reqq.urlretrieve(image_url,"D:\\instaimg.jpg")
This works fine. But this can only download one image. Is there any way to get the URL of all the posts of a user so that all images posted by the user can be downloaded? Any help would be appreciated. Thanks!
Aucun commentaire:
Enregistrer un commentaire