from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By import pandas as pd import regex as re import time # Set up Selenium WebDriver service = Service("chromedriver.exe") # Update with the path to your ChromeDriver driver = webdriver.Chrome(service=service) # Base URL of the topics base_url = "https://acharyaprashant.org/en/articles/topic/" # To store all the article URLs article_data = [] # Iterate over all 257 topic URLs for topic_id in range(1, 258): topic_url = f"{base_url}{topic_id}" try: driver.get(topic_url) time.sleep(2) # Allow time for the page to load fully # Run the JavaScript code to get all the divs article_divs = driver.execute_script( """ return Array.from( document.getElementsByClassName( "article-cell relative cursor-pointer p-4 hover:bg-surface-100 laptop:ml-4 laptop:pr-0 svelte-kyxxwg" ) ); """ ) # Extract the URLs from each div for div in article_divs: inner_html = driver.execute_script("return arguments[0].innerHTML;", div) matches = re.findall(r'