Results 1 to 4 of 4
  1. #1

    how would I check a website for a string?

    I'm currently working on a pet project of mine that involves having to check if a string is present in a specified webpage, using PHP. I probably have to end up downloading the source and then using preg_match(), but I am unsure how I would actually download the source and then read it in. Any help would be appreciated.

  2. #2
    is the string in PHP or is it an HTML tag? if its in PHP you wont be able to access it unless its your script on the same account.

  3. #3
    Sorry, i forgot to add, if you are checking the html from a foreign html document here is the code I use in HCL to check for updates..

    PHP Code:
        if ($HCL_update == "true") {
            if (!
    function_exists("file_get_contents")) {
    $UPDATE "You cannot check for updates as you are not running PHP 4.3";
            } else {
    $UPDATE_current = @file_get_contents("http//".$URL_maindir."&email=".$COMPANY_email);

                if (isset(
    $UPDATE_current)) {
    $UPDATE_description = @file_get_contents("http//".$URL_maindir."&email=".$COMPANY_email);
                    if (
    $UPDATE_current !== $HCL_version) {
    $UPDATE "<br />There is an update avaliable.<br /><br />Description:<br />".$UPDATE_description."<br /><br /><a href=\"http//\">Go to the Help Center Live website to download</a>";
                    } else {
    $UPDATE "You are using the latest version of Help Center Live";
                } else {
    $UPDATE "You have either chosen not to receive update notifications or there was an error whilst checking for updates";
    it uses the php function file_get_contents() which was new in PHP 4.3
    You need to put that in a string and then preg_match it

  4. #4
    It's in HTML. I'll try that code you posted, thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts