Paste data from a list to a webform - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Paste data from a list to a webform (/thread-32954.html) |
Paste data from a list to a webform - brunolelli - Mar-19-2021 Hello guys, I'm using the following code in order to collect some information from a website. import zapimoveis_scraper as zap import pandas as pd result = zap.search(localization="sp+sao-paulo", acao="aluguel", tipo="loja-salao", num_pages=5) ofertas = len(result) print(ofertas) df = pd.DataFrame([], columns=['Address', 'Price', 'Total Area', 'Bathrooms', 'Badrooms', 'Vacancies', 'Description']) for i in range(ofertas): df = df.append({'Address': result[i].address, 'Price': result[i].price, 'Total Area': result[i].total_area_m2, 'Bathrooms': result[i].bathrooms, 'Badrooms':result[i].bedrooms, 'Vacancies':result[i].vacancies, 'Description':result[i].description}, ignore_index=True) df.to_csv (r'C:\Users\bruno\Desktop\FII\Zap.csv', index = False, header=True, sep=';', encoding='utf-8-sig') print(df)And now, I would like to paste just the "column" Address from df on the field "input" of the following website: https://geocode.localfocus.nl/ Using the following code I can write my name on the field input, from selenium import webdriver import time from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import Select driver = webdriver.Chrome('C:/bin/chromedriver.exe') driver.get("https://geocode.localfocus.nl/") select = Select(driver.find_element_by_id('boundary')) select.select_by_visible_text("Brazil") driver.find_element_by_id("input").send_keys('Bruno')How can I write all information from Address on the field "input"? Thank you RE: Paste data from a list to a webform - snippsat - Mar-19-2021 It has been easier if you found a Geocoding API eg Google. Then get json back,faster and easier do deal than doing it like this. I can do a test. I import your first code zap_movie.py ,comment out line 14,15.# geo_location.py from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import Select from selenium.webdriver.common.action_chains import ActionChains import time import zap_movie #--| Setup options = Options() #options.add_argument("--headless") #options.add_argument('--log-level=3') driver = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options) #--| Parse or automation driver.get("https://geocode.localfocus.nl/") select = Select(driver.find_element_by_id('boundary')) select.select_by_visible_text("Brazil") time.sleep(3) # Insert from import adress_1 = zap_movie.df["Address"].iloc[0] print(adress_1) driver.find_element_by_id("input").send_keys(adress_1) # Click button driver.find_elements_by_css_selector('#geocode')[0].click() # Hit button = driver.find_element_by_class_name("panel-heading") time.sleep(3) ActionChains(driver).move_to_element(button).click(button).perform() time.sleep(3) print(driver.find_elements_by_css_selector('span.geo')[0].text)
|