View Single Post
Old 08-04-2012, 04:56 PM  
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Ah ok. If you're still interested in a php solution, maybe this?

Code:
if ( empty( $argv[1] ) ) die( 'Usage: php test.php keyword' . PHP_EOL );
$fp = fopen( 'links.txt', 'r' );
while( $line = fgets( $fp ) )
{
    if ( strpos( $line, '<h3>' ) !== false AND strpos( $line, $argv[1] ) !== false )
    {
        do {
            $line = fgets( $fp );
            if ( strpos( $line, '<h3>' ) !== false ) break 2;
            else echo $line;
        } while ( ! feof( $fp ) );
    }

}
fclose( $fp );
Output usage:

Code:
~ $ php test.php
Usage: php test.php keyword
~ $ php test.php search
<a href="http://google.com">google</a>
<a href="http://www.bing.com">bing</a>
<a href="http://www.yahoo.com">yahoo</a>
~ $ php test.php pay   
<a href="http://www.paypal.com">paypal</a>
<a href="http://www.paxum.com">paxum</a>
~ $ php test.php bleh
<a href="http://php.net">php</a>
<a href="http://nginx.org">nginx</a>

~ $ php test.php 'search engine links'
<a href="http://google.com">google</a>
<a href="http://www.bing.com">bing</a>
<a href="http://www.yahoo.com">yahoo</a>
~ $ php test.php 'payment links'      
<a href="http://www.paypal.com">paypal</a>
<a href="http://www.paxum.com">paxum</a>
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote