Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4068978
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:26:33+00:00 2026-05-20T16:26:33+00:00

I need to scrape the number 622104 from this html How can I get

  • 0

I need to scrape the number 622104 from this html

How can I get the number?

<div class="numbersBackground">
        <div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl00_numberPanel" class="number">
        <div class="numberWrapper"><span>6</span></div>
    </div><div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl01_numberPanel" class="number">
        <div class="numberWrapper"><span>2</span></div>
    </div><div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl02_numberPanel" class="number">
        <div class="numberWrapper"><span>2</span></div>
    </div><div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl03_commaPanel" class="comma">

    </div><div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl04_numberPanel" class="number">
        <div class="numberWrapper"><span>1</span></div>
    </div><div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl05_numberPanel" class="number">
        <div class="numberWrapper"><span>0</span></div>
    </div><div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl06_numberPanel" class="number">
        <div class="numberWrapper"><span>4</span></div>
    </div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:26:34+00:00Added an answer on May 20, 2026 at 4:26 pm

    Using the DOMDocument class to parse the HTML string, thanks to its loadHTML method, you could use an XPath query (using the DOMXpath class) to find all <div> tag with a class="numberWrapper" attribute.

    Then, iterate over those, concatenating their content to a variable — which, at the end of the loop, will contain your number.

    For example, you could have this kind of code :

    $str = <<<HTML
    ... HERE YOUR HTML ...
    HTML;
    
    $number = '';
    
    $dom = new DOMDocument();
    if ($dom->loadHTML($str)) {
        $xpath = new DOMXpath($dom);
        $results = $xpath->query('//div[@class="numberWrapper"]');
        foreach ($results as $div) {
            $number .= $div->nodeValue;
        }
    }
    
    var_dump($number);
    

    And, as output, you’d get :

    string '622104' (length=6)
    

    You could also use the following XPath query, to make sure you’re only working with the <span> tags :

    $results = $xpath->query('//div[@class="numberWrapper"]/span');
    

    Here, as the <div>s only contain the <span>, the result will be the same — but it might change, in other situations.

    Of course (just to make sure it’s said) : Regular Expressions are not the right way to extract informations from an HTML string.


    Edit after the comment :

    If there are other <div>s you don’t want to take into account, you’ll have to find another XPath query — that matches what you want to extract.

    For example, maybe something like this would do the trick :

    $results = $xpath->query('//div[@class="numbersBackground"]//div[@class="numberWrapper"]/span');
    

    Of course, up to you to find out exactly what matches your the structure of your HTML document.

    If you want to download the HTML, you have two solutions :

    • If allow_url_fopen is enabled on your server, you can use DOMDocument::loadHTMLFile(), passing it the URL as a parameter.
    • Else, you’ll have to download the HTML content, using, for instance, curl.

    As a sidenote, if you get warnings before your HTML is not valid, you’ll want to take a look at the libxml_use_internal_errors() function 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with my xpath query. I can get this code to
Can this be done if so, how? I want to scrape data from xbox.com
I need to scrape news announcements from this website, Link . The announcements seem
I need to scrape Form 10-K reports (i.e. annual reports of US companies) from
I need to scrape some data from webpages. But I have some encoding problems
I need to scrape some websites, and would like to avoid downloading images from
I need to scrape some content from a HTTP response with Java. The required
I need to scrape data from a site, but it requires my login first.
I need to scrape a site with python. I obtain the source html code
I need to scrape from a website that requires authentication, that is a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.