Issue
I am trying to search items in google's search bar where the items come from an excel spreadsheet. I have no issue importing the items from excel to python but my script never actually enters any of the items into Google's search bar. What is wrong with my loop? I want it to search every item in excel. Thanks.
from ast import Return
from operator import index
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pandas as pd
import time
df = pd.read_csv("C:\\Users\\Carson\\properties1.csv")
indexx = [df]
driver = webdriver.Chrome("C:/Users/Carson/Desktop/chromedriver.exe")
driver.get("https://www.google.com")
try:
for element in indexx:
search = WebDriverWait(driver, 7).until(EC.presence_of_element_located((By.NAME,'q')))
search.click()
search.send_keys(element)
search.send_keys(Keys.RETURN)
driver.back()
except:
print("Loop Failed")
driver.quit()
Solution
I solved my issue by using the line of code:
for i, row in df.iterrows():
Answered By - Carson Cramer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.