D
D
dinoeb2022-01-18 15:39:57
Parsing
dinoeb, 2022-01-18 15:39:57

There was a problem with importing data from selenium to csv. How to solve?

61e6b4ee09ffc288707301.png
Here such problem arose. Why are there commas?
The code is
import csv
from selenium import webdriver
from selenium.webdriver.common.by import By
import json
def main():
options=webdriver.FirefoxOptions()
options.set_preference('dom.webdriver', False)
options.set_preference(' dom.webnotifications.enabled', False)
options.set_preference('media.volume_scale', "0.0")
browser=webdriver.Firefox(options=options)
browser.get(' https://www.talabat.com/bahrain/ restaurant/41468/m... ')
name_of_restauran=browser.find_element(By.TAG_NAME,'h1')
with open('restauran_name.csv',
writer=csv.writer(file)
writer.writerow(name_of_restauran.text)
browser.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2022-01-19
@dinoeb

try like in documentation
https://docs.python.org/3/library/csv.html

writer = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)
writer.writerow([name_of_restauran.texе])

at least the argument is criticaldelimiter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question