So basically I have a list of URLs. I want to open each URL using webdriver simultaneously so the task can be achieved in a short span of time (instead of looping through each URL in the list).
Should I use Selenium Grid or is there a simpler way?
My code looks as follows:
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import time
from selenium.webdriver.common.keys import Keys
list = ['www.link1.com', 'www.link2.com','www.link3.com'....]
for i in list:
driver2 = webdriver.Chrome()
driver2.get(i)
time.sleep(1)
try:
finallinks = []
all_links = driver2.find_elements(By.XPATH, "/html/body/main/section[1]/div/section[2]/div/div[1]/div/div/div[1]/div/div/section/main/div[2]/form/div[2]/div/div/a")
print("HOLAAAAAA")
for a in all_links:
if str(a.get_attribute('href')).startswith("https://something/view") and a.get_attribute(
'href') not in finallinks:
finallinks.append(a.get_attribute('href'))
print(finallinks)
except NoSuchElementException:
print("Didn't exist")