greg duke Posted March 4, 2011 Share Posted March 4, 2011 Hi All, I'm new at php and I need your help. I'm trying to find a string in a website. I want my website to get a string on another website(I have full access) without really opening it on a browser. For example the string is "MyID=123456", i want to find "MyID=123456"(the MyID number is random and always changing but always 6 random numbers) on another website and output only "123456" on my website. Is this possible? Please help. Thanks Link to comment https://forums.phpfreaks.com/topic/229578-find-string-in-websitewebpage/ Share on other sites More sharing options...
beegro Posted March 4, 2011 Share Posted March 4, 2011 Try this out $page = file_get_contents('http://www.example.com/'); $sub = stristr($page, "myid="); $num = sub_str($sub, 0, 6); // assuming the value will always be six characters If you need to find the id for any variable length you'll have to split on the space after the value, but I'm sure you can figure the rest out. Link to comment https://forums.phpfreaks.com/topic/229578-find-string-in-websitewebpage/#findComment-1182836 Share on other sites More sharing options...
greg duke Posted March 4, 2011 Author Share Posted March 4, 2011 Try this out $page = file_get_contents('http://www.example.com/'); $sub = stristr($page, "myid="); $num = sub_str($sub, 0, 6); // assuming the value will always be six characters If you need to find the id for any variable length you'll have to split on the space after the value, but I'm sure you can figure the rest out. Thank you it worked. Link to comment https://forums.phpfreaks.com/topic/229578-find-string-in-websitewebpage/#findComment-1182925 Share on other sites More sharing options...
greg duke Posted March 6, 2011 Author Share Posted March 6, 2011 Thanks you for your help. One more thing, I can find any sting to a website expect if it is inside an frame, but in a browser when I right click the frame and view page source I can see the string I want to find. This is the link http://apps.facebook.com/cityville/invite.php. Please help if my problem can be resolved. Thanks! Link to comment https://forums.phpfreaks.com/topic/229578-find-string-in-websitewebpage/#findComment-1183539 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.