简体   繁体   中英

i want to scrape data from website using php

scraping perticular data from website using php without using any tools,i have tried this code but it is not sufficient-

<?php
$url = 'http://www.google.com';

$output = file_get_contents($url);
echo $output;
?>

you can used curl in php

<?  
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com'); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$data = curl_exec(); 
curl_close($ch); 
 ?> 

where $data contain html of given url

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM