Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function youtube_ro(){
- global $_COOKIE;
- $results = array();
- $html = file_get_contents("https://www.youtube.com/playlist?list=PLFgquLnL59akxkuW7czf5TvyjzcUMgaci") ;
- $dom = new domDocument;
- $dom->loadHTML($html);
- $dom->preserveWhiteSpace = false;
- $find_id = '/data\-video-id=\"(.*?)\"/';
- $find_title = '/data\-title=\"(.*?)\"/';
- $find_length = '/<div\sclass=\"timestamp\"\>\<span .*?\>(.*?)\<\/span\><\/div>/';
- $new_file = new DOMXpath($dom);
- $i = 0;
- if($new_file->query('//tr')->length>0)
- {
- foreach($new_file->query('//tr') as $table){
- $i++;
- preg_match($find_id, $table->C14N(), $id);
- preg_match($find_title, $table->C14N(), $title);
- $results[$i] = array(
- "id" => $id[1],
- "titlu"=> $title[1]
- );
- if($i>=100)break;
- }
- }
- return json_encode($results);
- }
- $test = youtube_ro();
- $list = json_decode($test, true);
- foreach ($list as $plm) {
- if(isset($plm['id']) && isset($plm['titlu']) && $pdo->query("select * from tabel where vid='".$plm['id']."'")->rowCount()==0) {
- echo "[+] ".$plm['id']." - ".$plm['titlu']."\n";
- $bib = $pdo->prepare("insert into tabel(titlu, vid) values (:titlu, :vid)");
- $bib->execute(array("titlu" => $plm['titlu'], "vid" => $plm['id']));
- //aici e inserarea in baza
- } else {
- echo "[-] ".$plm['id']." - ".$plm['titlu']."\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment