« Web, HTML, Tech Forum

removing a number from a span tag (which has no id or class) that is enclosed by div tags

Posted by Karl Shady

posted
updated

Forum: Web, HTML, Tech

I'm trying to scrape a webpage because I'm new to programming.


The website (online pokies australia real money) is an online casino, and I need to scrape just one of the numbers shown (the number contained in a particular position changes more or less every 30 seconds, but I will think about this later).

<div class="sc-qbELi jLgZIw">
<span>2</span>
</div>

The span tags that contain the number I want to scrape lack an id or class. Thus, I am unable to find them. Because of this, I considered identifying the div tag that includes the span tag and then scraping the number found there using functions like. Contents,.next element, or. Children.

The div tag can be found between several other div tags and is not the first div element in the HTML code, so where is it?



I set the link to the website and imported the modules:

Import BeautifulSoup from bs4

importing demands

urllib. request import

Website address: "https://pokieslab.com/real-money-pokies/"

Requests. get = response (URL)

BeautifulSoup = soup (response. text, "HTML. parser")

I experimented with the following three fixes:


div_tag = soup.findAll('div', class_='sc-qbELi jLgZIw')

div_tag = soup.find("div", class_="sc-qbELi jLgZIw")

div_tag = soup.select("div.jLgZIw.sc-qbELi")

The issue is that when these lines of code are written, they produce the following results: [], None, and []. Thus, I don't get anything when I try to add. Children or. Content to a div tag.


I would be grateful if you could guide me in figuring out how to achieve this. Thank you for your time.


Report Topic

0 Replies