I have list of URLs and i need to scrape data from them. The website refusing connection when opening each url in new driver, so i decided to open each url in new tab(the website allowing this way). Below code i am using
from selenium import webdriver
import time
from lxml import html
driver = webdriver.Chrome()
driver.get('https://www.google.com/')
file = open('f:\\listofurls.txt', 'r')
for aa in file:
aa = aa.strip()
driver.execute_script("window.open('{}');".format(aa))
soup = html.fromstring(driver.page_source)
name = soup.xpath('//div[@class="name"]//text()')
title = soup.xpath('//div[@class="title"]//text()')
print(name, title)
time.sleep(3)
But the problem is all URLs are opening at a time instead of one after one.