Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

download Twitter Images with BeautifulSoup

from selenium import webdriver
from selenium.common.exceptions import WebDriverException
import requests
import time

link = 'https://twitter.com/banprada/statuses/829102430017187841'
driver = webdriver.Chrome()
driver.get(link)
time.sleep(5) # To wait until all iframes completely rendered. Might be increased
iframe_counter = 0
while True:
    try:
        driver.switch_to_frame(iframe_counter)
        pictures = driver.find_elements_by_xpath('//img[@src and @alt]')
        if len(pictures) > 0:
            for pic in pictures:
                response = requests.get(pic.get_attribute('src')).content
                with open('C:UsersYouDesktopImages\%s.jpeg' % (str(iframe_counter) + str(pictures.index(pic))), 'wb') as f:
                    f.write(response)
        driver.switch_to_default_content()
        iframe_counter += 1
    except WebDriverException:
        break
Comment

PREVIOUS NEXT
Code Example
Python :: finding-the-largest-three-digits-number-within-a-number 
Python :: city of stars how many words in a song python code 
Python :: fiusion python lists 
Python :: python Tkinter widget displacement with pack() 
Python :: print(i) 
Python :: vscode show when variable is protected or private python 
Python :: Examples of incorrect code for this rule: 
Python :: python code sample submission of codeforces 
Python :: how to loop 10 times in python 
Python :: how to access specific index of matrix in python 
Python :: DOWNLOAD ANALYZE_DXP.PY 
Python :: Hide div element using python in Flask 
Python :: python tuple index access 
Python :: imprimir variables en python 
Python :: np sign no 0 
Python :: flask-sqlalchemy inserting a dictionary to a database 
Python :: ring load the odbclib.ring library 
Python :: ring Load Syntax Files 
Python :: create schema for table for django 
Python :: ret, img_frame = cap.read() 
Python :: set change order python 
Python :: unable to access jupiter assertions 
Python :: how to make levels in scratch 
Python :: phobia of butterflies 
Python :: how to perform a two-way anova with python 
Python :: mail.send_message flask not working, SSL == 465 
Python :: While importing we detected an older version of numpy in 
Python :: how travel a list invertida in python 
Python :: how to access item in list private in python 
Python :: put in something meaning 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =