Jump to content

Recommended Posts

Guys I'm trying to get a certain piece of info in the quickest possible way so the site don't load slow when fetching..

 

the site i'm getting data from is silverclix.com and the piece I wan't is the Total Paid and total Members at the top of the screen

 

the pieces of info are in this list

<!-- #statistics -->
        <div class="span8" id="statistics">
                	<section>
              <ul>
                <li class="total-paid">Total Paid: <span>$22,204.32</span></li>
                <li class="total-members">Total Members: <span>31912</span></li>
                <li class="users-online">Users Online: <span></span></li>                                      
              </ul>
            </section>
            
        </div>
        <!-- #statistics ends -->

and I have tried this...

<?php
			$content = file_get_contents('http://www.silverclix.com/index.php');

			preg_match('#<ul><li>(.*)total-paid</li></ul>#', $content, $match);
			$total_paid = $match[1];		
		
		?>

that hasn't worked so if anyone can help please   

Link to comment
https://forums.phpfreaks.com/topic/284749-how-can-i-extract-this-data/
Share on other sites

Don't use regular expressions to parse or navigate through HTML. Use DOMDocument to load it and then DOMXPath to get to that specific part of the HTML using the (untested) example query

//div[@id='statistics']/section/ul/li[@class='total-paid']/span

The documentation for DOMXPath::query has a relevant example - HTML versus XML doesn't really make a difference in what you do (beside changing a couple method calls). If you want to see the book.xml it uses, it's here.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.