Jump to content

explode, strpos, or regex?


phoenixx

Recommended Posts

Just wondering if anyone knows which method I should use for the following issue:

 

I'm scraping a page (in this case a craigslist ad) and trying to get the content between these two tags:

<div id="userbody">

and

<!-- START CLTAGS -->

.

 

I'm using a regex that isn't returning anything, but would it be cleaner just to explode or strpos the string?

 

Here's the code I'm using:

$data = @file_get_contents('http://houston.craigslist.org/fud/1704346680.html');
preg_match('/class="userbody">([^"]*)<!-- START CLTAGS -->/is',$data,$resultscontent);
echo $resultscontent[1];

 

Thanks in advance for your help.

Link to comment
https://forums.phpfreaks.com/topic/199399-explode-strpos-or-regex/
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.