I have this code that scrapes a website for pricing data, just for one particular product. However, making it headless makes it run twice as slow as compared to without headless. Shouldn't it be faster to be running headless instead of without? What is causing this issue??? Running on a browser takes about 6 seconds from start to finish. Running it headless takes 13 seconds instead.
timerstart = time.time()
url ='https://www.newegg.com/global/sg-en/corsair-32gb/p/N82E16820236991?Item=N82E16820236991&cm_sp=Homepage_SS-_-P2_20-236-991-_-01072024'
driver = Driver(uc=True, block_images=True, headless=True)
driver.get(url)
dollars = driver.find_element("xpath","//*[@id=\"app\"]/div[3]/div/div/div/div[1]/div[1]/div[1]/div/div[1]/div[2]/strong").text
cents = driver.find_element("xpath","//*[@id=\"app\"]/div[3]/div/div/div/div[1]/div[1]/div[1]/div/div[1]/div[2]/sup").text
priceofproduct = ""
priceofproduct = str(dollars)+str(cents)
priceofproduct = float(priceofproduct)
print(priceofproduct)
driver.close()
timerend = time.time()
print("Time elapsed: " + str(timerend-timerstart))