| | |
Find text on an external html site
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 4
Reputation:
Solved Threads: 0
Hi all,
Would anyone know how to search an external html file for a work or phrase ?
I was thinking something like -
Unfortunently, that doesn't work, but you get the jist of what I'm attempting.
Any ideas, suggestions, code would be greatfully appreciated,
Thanks,
Smoonie
Would anyone know how to search an external html file for a work or phrase ?
I was thinking something like -
PHP Syntax (Toggle Plain Text)
<?php $fp = fopen('http://www.google.ca', 'r'); if (preg_match('/Google.ca/', print fgets($fp))) { echo "match"; } else { echo "no match"; } ?>
Any ideas, suggestions, code would be greatfully appreciated,
Thanks,
Smoonie
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
I think what you're describing is called "screen scraping". There's an article on my site specifically about PHP screen scraping: http://www.tgreer.com/class_http_php.html
Of course, support DaniWeb. If you'd like to discuss that article, you can do so in this thread. The article author is also a DaniWeb member.
Of course, support DaniWeb. If you'd like to discuss that article, you can do so in this thread. The article author is also a DaniWeb member.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Whoops! I see that same article has also been posted as a daniweb code snippet:
http://www.daniweb.com/code/snippet293.html
http://www.daniweb.com/code/snippet293.html
I'm the author of those articles and the class. It is posted here on Daniweb, but the article version at www.tgreer.com provides a lot more in-depth explanation of usage.
sm00nie, check out PHP's stripos() function. It is what you are looking for I believe.
http://us2.php.net/manual/en/function.stripos.php
sm00nie, check out PHP's stripos() function. It is what you are looking for I believe.
http://us2.php.net/manual/en/function.stripos.php
Oops, stripos() is only available in PHP5, so check out strpos().
http://us2.php.net/manual/en/function.strpos.php
http://us2.php.net/manual/en/function.strpos.php
•
•
Join Date: Jun 2005
Posts: 4
Reputation:
Solved Threads: 0
PHP Syntax (Toggle Plain Text)
<?php $str_result = fopen("http://www.google.ca", "r"); while (!feof($str_result)) { $buffer = fgets($str_result, 4096); $result = strpos($buffer,"Google.ca"); echo $result; } fclose($str_result); ?>
Thanks fellas, I was starting to pull out what little hair I have left
![]() |
Similar Threads
- Send a text message to your phone from your site! (ColdFusion)
- Connecting a forum with an HTML site. Help plz (HTML and CSS)
- help with regex...and marking up text in JTextpane with html (Java)
Other Threads in the PHP Forum
- Previous Thread: Parse error: parse error, unexpected T_STRING in /home/thei2k9/public_html/includes/f
- Next Thread: Deleting a foreign cookie
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error errors execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javascript joomla keywords limit link login loop mail menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect remote script search securephp server sessions shot sms source space sql subscription syntax system table tutorial tutorials update upload url validator variable video web youtube






