How To Scrap Data Of Any Website Using Curl


Hello friends ajj me apko btaunga ki kis parkar ham kisi b website ka data scrap kar sakte hai Curl and File_get_contents Function Ka Use Karke-


steps-

1-make a simple html form-sabse pehle ek html form create kar lijiye jiski madad se user webaddress enter karke submit karega
2- make a function-ab ham ek scrap name se fucntion create karege janha ham curl ko initialize and iske sare operation karege


Method1-How to scrap DATA with Curl-



<form method="post" id="scrap_form" action="">

Enter Website URL To Scrape Data<br>

<input type="input" name="website_url"><br>

<input type="submit" name="submit" value="Submit" >

</form>





<?php

function Scrap($website_url){



$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $website_url);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($curl);

curl_close($curl);

return $output;

}





if(isset($_POST['submit'])){

$html = Scrap($_POST['website_url']);



echo $html;

}








Method2-How To Scrap Data With file_get_contents-






<form method="post" id="scrap_form" action="">

Enter Website URL To Scrape Data<br>

<input type="input" name="website_url"><br>

<input type="submit" name="submit" value="Submit" >

</form>



<?php



if(isset($_POST['submit'])){

$website_url=$_POST['website_url'];



$homepage = file_get_contents($website_url);

echo $homepage;



}





?>

is parkar aap easily data scrap kar sakte ho .
aap niche diye link se demo check kar sakte ho

Demo Scrap Data From Website
Thank You
Team Gajabwap Web In Hindi
also read-
How to get cricket live score with php
Previous
Next Post »

1 comments:

Click here for comments
Unknown
admin
25 June 2018 at 12:14 ×

nice Code bro keep it up good work... code is nice

Congrats bro Unknown you got PERTAMAX...! hehehehe...
Reply
avatar
Thanks for your comment