Re: regular expressions or something else?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/12/06, Chris Westbrook <westbc@xxxxxxxxx> wrote:
> I have a problem.  I'm trying to get a Google search results page via snoopy
> and then display the links of the results it returns in an application.  I
> know about the fetchlinks function in snoopy, but I'm having trouble getting
> the text between the <a> and </a> tags.  Yeah, I know, I should use the
> Google API, but my client doesn't want me doing that, probably because they
> might have to pay for that.  any suggestions?

Try this, and read up on regular expressions - it's an essential
knowledge if you're a programmer.

$text = "this is where the contents of your search result page goes";
preg_match_all('|<a[^>]*href="([^"]+)"[^>]*>([^<]+)<\/a>|U', $text,
$links, PREG_SET_ORDER);
print_r($links);

--
Kim Christensen
kim.christensen@xxxxxxxxx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux