How To Extract The Value From The By Using Selenium
So i'm using selenium webdriver to parse date from web site by (class_name, tag_name, Xpath, css_selector) and all my attempts to fetch data are unsuccessful. And in this exapmple
Solution 1:
you have put "tr' in soup.find_all('tr')
so you tr(table) header. if you put 'td' there then you will get td(row) data. When reading the table, you can also try pandas.read_html method which in many scenarios will be helpful.
import pandas as pd
from bs4 import BeautifulSoup
html_src="""
<table data-v data-qa="table" class"table">
<tr data-v>
<th data-v> Name </th>
<th data-v> Last_name </th>
<th data-v> Phone </th>
<th data-v> City </th>
<th data-v> Salary </th>
</tr data-v>
<tr data-v data-qa="table-row">
<td data-v class="table-name not-editable">Tetyana</td>
<td data-v class="table-last-name not-editable">Ferguson</td>
<td data-v class="table-phone not-editable">252-823-1658</td>
<td data-v class="table-city not-editable">Tarboro</td>
<td data-v class="table-salary not-editable">10000</td>
</tr data-v>
<tr data-v data-qa="table-row">
<td data-v class="table-name not-editable">Alyonka</td>
<td data-v class="table-last-name not-editable">Andrews</td>
<td data-v class="table-phone not-editable">603-608-7504</td>
<td data-v class="table-city not-editable">Northwood</td>
<td data-v class="table-salary not-editable">12000</td>
</tr data-v>
</table>
"""
option 1:
df=pd.read_html(html_src)
print(df[0].head(10))
#output
Name Last_name Phone City Salary
0 Tetyana Ferguson 252-823-1658 Tarboro 10000
1 Alyonka Andrews 603-608-7504 Northwood 12000
option 2:
soup=BeautifulSoup(html_src)
for each in soup.find_all("td"):
print(each.get_text())
#output:
Tetyana
Ferguson
252-823-1658
Tarboro
10000
Alyonka
Andrews
603-608-7504
Northwood
12000
Post a Comment for "How To Extract The Value From The By Using Selenium"