Jump to content

Is there a SED equivalent in PHP


prosper99

Recommended Posts

Hi Guys/Gals,

 

Writing a basic website page scraper and have run into a (mental) road block.  I need to scrape a basic webpage and search  the contents for a specific string, once I find that string I need to extract a 10 digit number that sits on the same line where the string was found.. I'm not able to call sed to do this, so is there away with just PHP?

 

Here is an example of a scrape code;

 

I use this to pull the site...

 

$url = 'http://anywebsite.com/list/sus/';

$output = file_get_contents($url);

 

Now, in that output there will be a line like the one below with the string I need to search for "matching text".  Is there a way to just extract the 10 digit number and assign to a variable?

 

href="http://site.website.com/list/tor/1234567890.html">matching text/a> -  <span class="p"> pic</span

 

Thanks for any assistance you can provide..

 

Cheers,

Rob

 

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.