Hello. I'm a python beginner.
I want to store the scraped data in selenium in order and output it, but it doesn't work.
Currently in the arry list with the corresponding code below
["Text element", "Text element", "Text element" ....], ["Number", "Number", "Number", ...], ["Text element 2" "Text element 2" "Text element 2" ....]
It is output like this, but for me
[["Text element", "Number", "Text element 2"] ["Text element", "Number", "Text element 2"] ["Text element", "Number", "Text element 2"]. .....]
I want to store each set in the list like this, what should I do? ?? Would you please help me? ?? Thank you.
What I tried
from selenium import webdriver import chromedriver_binary from selenium.webdriver.common.keys import Keys from selenium.webdriver.chrome.options import Options import urllib.request options = Options () options.headless = True options.add_argument ('--headless') driver = webdriver.Chrome (options = options) driver.get ("Scraping site URL") arry =  selector ='text element' element = driver.find_elements_by_css_selector (selector) element = [a.get_attribute ("href") for a in element] date_element = "number" dates = driver.find_elements_by_css_selector (date_element) dates = [b.text for b in dates] i ='text element 2' items = driver.find_elements_by_css_selector (i) items = [c.text for c in items] arry.append ((element, dates, items)) print (arry) for q in arry: print (q)
Should I turn it with a for statement? And finally
for q in arry:
I wrote code like this and the result was the same. I'm sorry, I would like to ask you to teach. Thank you.
Answer # 1
zipped = zip (element, dates, items) print (zipped) # [("text element", "number", "text element 2"), ("text element", "number", "text element 2")]
I should do it.
itemsI don't think they are the same number,
The original format doesn't seem to be a problem.
Answer # 2
Whether to use zip () as unhappychoice answers
Or using numpy
.TIt is possible to transpose as follows.
import numpy as np array = [['a','b','c'], [1, 2, 3], ['a','i','u']] print (np.array (array) .T) >>>[['a' '1''a'] >>>['b' '2''I'] >>>['c' '3''u']]
- python - the bet365 site cannot be scraped with selenium if you are familiar with it, could you please tell me?
- data scraped by selenium using python cannot be stored in the list just by the for statement
- python - i want to display data scraped by selenium in a table using a for statement in a django template
- python - i want to store an object in an array
- python - how to store tkinter input values in mysql
- how to create as many dictionaries as there are scraped lists in python?
- python - ec2 selenium garbled characters
- python - [selenium] about element specification in find_element_by_css_selector
- python - i want to store multiple json files in sqlite at once using glob
- in python selenium, i want to get the element of the button of the site from class name, but it fails with nosuchelementexceptio
- [python] selenium i want to operate the window that appears by clicking
- python - unable to get element with selenium
- python - how to process scraped data
- python - how to remove a list from a tuple and store only the value
- python - "view page source" in selenium
- python selenium get dynamic class name during scraping
- i want to store data using a for statement using a table in html in python, but it is not displayed well
- python 3x - [python] [selenium] i get an error when i put a variable in find_element_by_xpath
- python - how to store the characters in the list in the dictionary
- python - i can't get the element with selenium
- python - how to get "job description" of hello work with selenium
- [python] i can't open a new firefox tab in selenium a new window will open
- python - whether scraping is possible
- python - i'm using selenium the text sent by send_keys to the input tag disappears when the text is sent by send_key to the next
- python - how to hide the browser by scraping with beautifulsoup
- python seleniun error modulenotfounderror: no module named'selenium'
- python - i can't use special keys with selenium
- python - currency scraping json
- i want to change the display of the weather forecast python weather api