Jump to content

Find string in website/webpage


greg duke

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.