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
https://forums.phpfreaks.com/topic/192292-is-there-a-sed-equivalent-in-php/
Share on other sites

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.