gfro_za gfro_za - 15 days ago 6x
Python Question

Webscraper in Python - How do I extract exact text I need?

Good day

I am trying to write my first webscraper. I have managed to write the following:

import requests
from bs4 import BeautifulSoup

s = requests.Session()

r = s.get("")

r ="")

soup = BeautifulSoup(r.text, "html.parser")
print(soup.find_all("td", class_="dataCell"))

I am trying to extract a share price. When Inspect the element this is the HTML code:

<td class="dataCell" align="right">85221</td>

Image of share price table

Basically, my issue is that can search for all the tags but can't extract the exact tag I want.

Thanks in advance for any help.


Tags have a get_text() method. find_all returns a list of tags.

for cell_tag in soup.find_all("td"):