I'm scraping data off of a website and I need to insert each li element text into its own row on a MySQL table.
Source
https://printcopy.info/?mod=erc&brand=Kyocera&model=TASKalfa+2460ci&page=1
This codes prints out all text from each li
parent = driver.find_elements_by_class_name("ercRow")
for link in parent:
links = link.find_elements_by_tag_name('li')
for l in links:
print(l.text)
Results
Code:...
Description:...
Cause:...
Remedy:...
I now need to turn each li into its on variable so I can insert them into a mysql table like this:
id | code | desc | caus | reme
1 code... desc... cause... reme..
2 code... desc... cause... reme..
3 code... desc... cause... reme..
I tried:
parent = driver.find_elements_by_class_name("ercRow")
for link in parent:
links = link.find_elements_by_tag_name('li')
for l in links:
print(l[0].text)
print(l[1].text)
print(l[2].text)
print(l[3].text)
Error:
print(l[0].text)
TypeError: 'WebElement' object is not subscriptable
Any help would be greatly appreciated. Thank you.