doa24uk Posted July 25, 2009 Share Posted July 25, 2009 Hi guys, I'm wondering if someone could advise or point me in the direction of a good tutorial for the following. Let's say I have two pages. A & B Page A contains a link to Page B I want to check for certain text contained on Page B (it will always be in the same place. So, if Page B says <div id=mydiv>Positive Negative</div> Then I can code something in php (this bit I can do) to update Page A with the text Unfortunately, Page B Result was NEGATIVE Otherwise it will post something on Page A saying Great, Page B Result was POSITIVE --- Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/167376-curl-to-check-for-certain-text-on-a-webpage/ Share on other sites More sharing options...
papaface Posted July 25, 2009 Share Posted July 25, 2009 Regex is your best option, although I'm not the best at regex so I'd probably do something like: $file = file_get_contents("a.php"); $split = explode('<div id=mydiv>Positive Negative</div>',$file); if (count($split) > 1) { //div was found } else { //div was not found } Admittedly, this is not the best way to do it, but it will work. Link to comment https://forums.phpfreaks.com/topic/167376-curl-to-check-for-certain-text-on-a-webpage/#findComment-882581 Share on other sites More sharing options...
doa24uk Posted July 25, 2009 Author Share Posted July 25, 2009 Regex is your best option, although I'm not the best at regex so I'd probably do something like: $file = file_get_contents("a.php"); $split = explode('<div id=mydiv>Positive Negative</div>',$file); if (count($split) > 1) { //div was found } else { //div was not found } Admittedly, this is not the best way to do it, but it will work. Sorry, I should have mentioned that a.php in your example & Page B will be an offsite page therefore this won't work Link to comment https://forums.phpfreaks.com/topic/167376-curl-to-check-for-certain-text-on-a-webpage/#findComment-882607 Share on other sites More sharing options...
doa24uk Posted July 26, 2009 Author Share Posted July 26, 2009 ^bump^ Link to comment https://forums.phpfreaks.com/topic/167376-curl-to-check-for-certain-text-on-a-webpage/#findComment-883518 Share on other sites More sharing options...
thewooleymammoth Posted July 27, 2009 Share Posted July 27, 2009 im pretty sure it will still work as he said if i remember right you can get file contents from their page $file = file_get_contents("http://google.com"); $split = explode('<div id=mydiv>Positive Negative</div>',$file); if (count($split) > 1) { //div was found } else { //div was not found } Link to comment https://forums.phpfreaks.com/topic/167376-curl-to-check-for-certain-text-on-a-webpage/#findComment-883568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.