I need a way to load an HTML file from a server, read the file, then parse it so that that extracts a number from inside two HTML tags.

This is the setup.....

<a HREF="/tracker/161242">3873</a>

I need to get this <a HREF="/tracker/161242">XXXXXXX</a>
X being a number.

The parsing must be able to find numbers in between those two tags no matter how big the number is.

Can anyone help me? I have never created a parsing engine.

    Do you need the number after the link is clicked, or as the page with the link on it loads?

      $test1 = preg_replace("'<[\/!]?[<>]?>'si", "",$test1);

      $test1 should then be the line with all html tags stripped out.

        First, look into Snoopy for fetching remote web pages, if that's what you're after.
        http://snoopy.sourceforge.com

        or try reading the manual on file functions.

        now for probably the simplest, worst links regular expression/parser ever:

         
        <?php
        
        $html='<HTML><HEAD><TITLE> </TITLE></HEAD>';
        $html.='<BODY><A href="/tracker/161242">3873</a>';
        $html.='<a href="/tracker/161242">XXXX</A></BODY></HTML>';
        
        get_inner($html);
        
        function get_inner($input){
        
        preg_match_all("/(<(a|A) |HREF=.*>)(.*)(<\/(A|a)>)/", $input, $links);
        
        foreach($links[0] as $link){
        $inner=strip_tags($link);
        echo $inner;
        }
        
        }
        
        ?>
          
          Write a Reply...