Page 1 of 1

How to: Web Scrape/ Parse a website and return content

Posted: Tue Apr 08, 2008 12:04 am
by medit
Hello all,
I'm quite a newbie to the php language. But was hoping after more than a few hours of search online if someone could help me with the following with some working sample code:

1. I have a website that I want to parse/scrape.
2. I have a text pattern.

Question:
1. Does anyone have an working sample code that I can take a look at?

any help would be appreciated.

Re: How to: Web Scrape/ Parse a website and return content

Posted: Tue Apr 08, 2008 2:28 am
by Kadanis
You could try

Code: Select all

 
 
$page_content = file_get_contents('http://www.url-here.tld');
 
...#parsing code here
 
 
I've seen it used before to get web site code and parse it. If that's what you're after. I think the only limitation is that the PHP server option allow_url_fopen must be on for this to work.

The alternative (although I've never done this) which I turned up through 1 google search, is to use Curl.

http://wiki.dreamhost.com/index.php/CURL