Hello guys,
I'm trying to save some data that I collected from a website textform, on a csv file.
And for that I'm using the following code, but I'm getting the error: 'str' object has no attribute 'to_csv'
How can I save the data from contents on a CSV file?
I'm trying to save some data that I collected from a website textform, on a csv file.
And for that I'm using the following code, but I'm getting the error: 'str' object has no attribute 'to_csv'
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)
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')
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")
teste = df['Address']
numero = len(teste)
follow_loop = range(0, numero)
for i in follow_loop:
driver.find_element_by_id("input").send_keys(teste[i] + ", São Paulo"+ "\n")
driver.find_element_by_id("geocode").click()
time.sleep(60)
contents = driver.find_element_by_id('result-geo').get_attribute('value')
contents.to_csv(r'C:\Users\bruno\Desktop\FII\LL.csv')What's going on? Whey am I getting this error?How can I save the data from contents on a CSV file?
