I'm trying to pull some text from a webpage. The page source that I want to pull data from is:
<tbody>
<tr class="drx_dotted">
<td class="drx_first">
<span name="pharmacy"
longitude="-82.531457"
latitude="42.617612"
pharmacyname="CVS Pharmacy #"
address="1025 St Clair River Dr"
city="Algonac"
state="MI"
zip="48001"
phone="8107944941">
</span>
<p>
<strong>CVS Pharmacy #</strong><br />
1025 St Clair River Dr<br />
Algonac, MI 48001<br />
1-810-794-4941
</p>
<p>
<a class=""
data-ajax="true"
data-ajax-method="post"
data-ajax-success="UpdateSearchPharmacyList"
href="/pfdn/SharedPharmacy/AddNetworkPharmacy?pharmacyNABP=2352324&language=English">Add Pharmacy
<span class='HiddenText'> CVS Pharmacy #</span>
</a>
</p>
</td>
<td>
<p>
Retail
</p>
</td>
<td>
<p>
Not applicable
</p>
</td>
</tr>
I want to pull the "Not applicable" near the bottom of the HTML code. It is the "p" in the third "td" in the HTML source code. There are also a bunch of these, so I want to pull all these tags at once into a python list.
Here is the selenium code I'm using to find the HTML:
x = driver.find_elements_by_xpath(
'//[@id="divSearchResultContainer"]/div[2]/div[2]/table/tbody/tr/td[3]/p')
When I type print(x) it prints out this:
[<selenium.webdriver.remote.webelement.WebElement object at 0x101f98210>,
<selenium.webdriver.remote.webelement.WebElement object at 0x101f98250>,
<selenium.webdriver.remote.webelement.WebElement object at 0x101f98290>]
So selenium has found and pull three instances (which is correct, it was supposed to find three). However, when I try to pull the text using;
print x[0].text
the output is:
None
I've tried a bunch of variations, even trying to find each element individually, but it's still not working. Has anyone had this problem? How can I resolve it?
Thanks
print x[0].textto be?dir(x)and see what is valid for it