I want to collect information from web pages.
Currently I copy and paste the information or address details in to excel then i export it to the database from the web pages.
Could i do this using php. If so how?
With Regards,
Jawahar
How to Collect data from websites
Moderator: General Moderators
-
phpjawahar
- Forum Newbie
- Posts: 19
- Joined: Thu Jan 12, 2012 6:06 am
- Location: Chennai, India
Re: How to Collect data from websites
Hi,
Yes you can get data from another web site.
You can achieve this using cURL or file_get_contents.
cURL Example:
file_get_contents Example:
Something like this.
Yes you can get data from another web site.
You can achieve this using cURL or file_get_contents.
cURL Example:
Code: Select all
$url = 'http://your-website-to-crawl-data.com;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
// you can do something with $data like explode(); or a preg match regex to get the exact information you need
echo $data;file_get_contents Example:
Code: Select all
$text = file_get_contents('http://your-website-to-crawl-data.com/') ;
preg_match ("/<!--start product-->([^`]*?)<!--end product-->/", $text, $temp); // get data out of the page
echo htmlentities($temp[0]) ; // splits out the 1st occurance of your dataSomething like this.
-
phpjawahar
- Forum Newbie
- Posts: 19
- Joined: Thu Jan 12, 2012 6:06 am
- Location: Chennai, India
Re: How to Collect data from websites
Thanks for your help.
Could you give me any tutorial site to learn more on this.
With Regards,
Jawahar
Could you give me any tutorial site to learn more on this.
With Regards,
Jawahar