Parsing data?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davidbeck12
Forum Newbie
Posts: 4
Joined: Fri Apr 11, 2008 9:29 pm

Parsing data?

Post by davidbeck12 »

Dear Readers

I want to know how can I parse data from one website ,(for example I want to parse name ,address,phonenumber ),show it on to another website ?In nutshell I want to see data from other sites and put it into my website.

Best Regards
David
m4rv5
Forum Newbie
Posts: 13
Joined: Fri Apr 11, 2008 12:49 am

Re: Parsing data?

Post by m4rv5 »

You could use cURL to access the file if its enabled then pass the content to a variable. Then you could use regex (preg_match/ preg_match_all) on the captured content to extract the data you need.

if cURL is disabled, fopen will also do.
davidbeck12
Forum Newbie
Posts: 4
Joined: Fri Apr 11, 2008 9:29 pm

Re: Parsing data?

Post by davidbeck12 »

Thankyou fo replying!!
I want to know how to get strated with curl?I dont know php.

Thanks in advance.
m4rv5
Forum Newbie
Posts: 13
Joined: Fri Apr 11, 2008 12:49 am

Re: Parsing data?

Post by m4rv5 »

try this code:

Code: Select all

<?php
$url = 'http://forums.devnetwork.net/viewtopic.php?f=1&t=81316';
$htmlDataToParse = getWebContent($url);
print_r($htmlDataToParse);
 
function getWebContent($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
 
?>
You could continue reading more about cURL here: http://php.net/manual/en/book.curl.php

Hope that helped.
davidbeck12
Forum Newbie
Posts: 4
Joined: Fri Apr 11, 2008 9:29 pm

Re: Parsing data?

Post by davidbeck12 »

Thankyou for replying once again!!

I just found WAMP which works well with PHP and cURL.Any suggestions?

I am not sure thats why wanted to have your expert advice.

Best Regards
David
Post Reply