Member-only story
Last time I tried to extract all the information with Selenium, but it’s not stable. So I decided to combine Selenium and BeautifulSoup to get the data. I search “FFXIV” and the Selenium will keep scrolling down and open all the videos on the page. On the video page, the title, published date, description, views and likes will be extracted by BeautifulSoup.
- Check the Selenium setup here
- Extract video information, and save it as a CSV file
- Add the keep scrolling function to get more video information (Not finished…)
1. Previous code
from selenium import webdriverfrom selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManagerfrom selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ECdriver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://www.youtube.com/results?search_query=ffxiv")driver.execute_script("window.scrollTo(0,document.body.scrollHeight)")video_list = driver.find_elements("xpath", '//*[@id="video-title"]')
links =…