Jump to content

Check webpage for specific text


Kiwi Chris

Recommended Posts

Hi,

 

I really know very little about php.

 

I am wanting to find a way check a specific number on a foreign website.

 

Two websites are involved Site A (Mysite) and Site B (external Site)

 

Site A - user gets a random code

 

That user adds this random code to site B

 

The user then comes back to Site A and clicks next

 

Site A script goes to Site B and checks the page for that random code

 

If that code has been added then open another page on Site A.

 

...............

 

I have asked around but no one has been able to help me.

 

I was suggested to use file_get_content to get the data

and function rand()  for the random code.

 

........................

 

From my understanding I would create a form that provides the user with the random code

and a button they press after adding the code to site B.

 

When the button is pressed file_get_content is used to check the code is there and if it is moves to next page of registration,

and if fails an error message.

 

.......................

 

I am not afraid of trying to make this code I really just have no idea where to go to get the information I need to do this.

 

I would really appreciate any helpful information you may be able to assist me with.

 

Kind Regards

Kiwi Chris.

Link to comment
https://forums.phpfreaks.com/topic/170814-check-webpage-for-specific-text/
Share on other sites

Sadly I am still very lost after reading both of these sites.

 

This is why I thought the only way was to ask here.

 

with file_get_content i see theirs a way to get information from a URL, I see you can set this to the amount of data you want.  I didn't see how you could look for a specific data in that page.

 

With cURL I saw a script for looking for books on amazon I could not figure out how I would go about changing this to find a random code on a page.

 

I realize it is important to search and to try to figure these things out on ones own and believe me I have tried I really do need a little direction.

 

 

 

 

 

Here you go. In this example I am checking to see if www.mywebsite.com is found at http://www.abc.com

<?php
function checkRemoteValue($url, $value) {
ob_start();
if(!@readfile($url)) {
	return false;
}
$body = ob_get_contents();
ob_end_clean();
if(stristr(htmlentities($body),$value)) {
	return true;
}
return false;
}


// usage
if(checkRemoteValue("http://www.abc.com", "www.mywebsite.com")) {
print "found";
}
else {
print "not found";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.