Search code examples
pythonweb-scrapingbeautifulsouppython-webbrowser

Get Element using BeautifulSoup that does not have a class in HTML


I am trying to get the text of the user's rank from this webpage. By "rank" I mean the text you see in the top right corner of the user's info:

here

In this example rank is "Competitions Master". So how do I get that text?


Solution

  • If you see clearly after inspecting the rank there's <a href = "/progression" inside of which is a <p> tag and inside of which there's again a <p>tag which contains the rank.

    First find the container with <a href = "/progression" and then find all the <p> tags inside it then again find all <p>. Print the text present inside the <p>tag as there is only one <p> tag inside<a href = "/progression" then <p>.

    Or there's a second method too: There's a button below "Home" with the name of the rank. You can try scraping that element.