How To Scrap Youtube channel Videos With Data Api v3 In Php



Steps-

1-open https://console.developers.google.com/

2-click on select a project-yanha par new project create kar lijiye





3-kisi be name se aap project teyar kar sakte ho



4-project name enter karke create button par click kijiye





5- ab apke dwara bnaya gya project open kijiye







6-ab top header me search bar hoga wanha par “youtube data api” likhkar search kijiye ab apke pass youtude data api v4 ka option ayega us option par click kijiye

7-ab aap youtube data api ko enable kar lijiye,enable button par click kijiye





8-ab left me crenditianal ka option hoga wanha par click kijiye




9 ab create creditianal par click kijiye

10 ab api par click kijiye







11 is parkar apki api key generate ho jayegi. Aap yanha se jo api key apko milegi aap use copy kar lijiye. Or niche diye gye code me paste kar dijiye








Index.php



<form action="" method="POST"   enctype="multipart/form-data"/>

<img src="youtubeapi.jpg">

<br>

<br>

YOUTUBE CHANNEL ID:

<br>

<input type="text" name="channelID"  placeholder="Enter YOUTUBE CHANNEL ID Here" size="50%" />

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

</form>







<?php

error_reporting(0);

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



$API_key    = '
enter Your Api Key Here';

$channelID  = $_POST['channelID'];

$maxresults = 5;//yanha aap jitni videos page par chahte ho wo number add kijiye jese me 5 videos chahta hu to mene 5 likha hai



$videoList = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='.$channelID.'&maxresults='.$maxresults.'&key='.$API_key.''));









foreach($videoList->items as $item){





        echo '<iframe  width="200" height="180" frameborder="100px"   src="https://www.youtube.com/embed/'.$item->id->videoId.'"></iframe>

          <h4>'. $item->snippet->title .'</h4>';

     }

















}



?>



App is data api ka use karke or be information scrap kar sakte ho-

$item->snippet->channelTitle

• $item->snippet->thumbnails->high->url

• $item->snippet->thumbnails->medium->url

• $item->snippet->thumbnails->default->url

• $item->snippet->description

• $item->snippet->publishedAt







Aap demo niche diye link se check kar sakte ho



Demo-


Scrap any Youtube Videos With Php





Is parkar aap youtube data api ka use karke easily apni website par youtube videos ko scrap kar sakte hai


get data from another website using php curl
scrape content from website php
learn how to extract data from websites with php
web scraping php
scrape youtube php
simple html dom
how to get data from another website in php

Agar apko koi problem a rhe hai to aap comment me puch sakte ho

Thank You

Team Gajabwap Web In Hindi


Previous
Next Post »
Thanks for your comment