Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function curl($url){
- // inisialisasi CURL
- $data = curl_init();
- // setting CURL
- curl_setopt($data, CURLOPT_URL, $url);
- curl_setopt($data, CURLOPT_HEADER, 0);
- curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($data, CURLOPT_URL, $url);
- // menyamar menjadi bing
- curl_setopt($data, CURLOPT_REFERER, 'https://www.google.com');
- curl_setopt($data, CURLOPT_SSL_VERIFYPEER, false);
- // agar tidak di curigai oleh bing
- curl_setopt($data, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; U; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
- curl_setopt($data, CURLOPT_FOLLOWLOCATION, true);
- // menjalankan CURL untuk membaca isi file
- $response = curl_exec($data);
- curl_close($data);
- return $response;
- }
- // proses
- $url = 'http://keepvid.com/?url=https://www.youtube.com/watch?v=Z62eeT0bXuk';
- $feed = curl($url);
- $content = explode('<div class="d-info2"><dl>',$feed);
- $content = explode('</dl></div>',$content[1]);
- $content = htmlspecialchars_decode($content[0]);
- //$content = str_replace(['var __mxmProps = {"pageProps":{"pageName":"trending-page"}};var __mxmState = ',';'], '', $content);
- //hasil
- //echo $content;
- //$api = file_get_contents(''.$content.'');
- //$json = json_decode($content,true);
- //foreach ($json['page']['tracks']['list'] as $as){
- //print_r($as);
- //echo ''.$as['name'].'<br/>';
- //echo ''.$as['artistName'].'<br/>';
- //echo ''.$as['commontrackVanityId'].'<br/>';
- //echo ''.$as['albumCoverart350x350'].'<br/>';
- //}
- $doc = new DOMDocument();
- $doc->loadHTML($content);
- $anchors = $doc->getElementsByTagName('a');
- foreach($anchors as $node) {
- echo $node->textContent;
- if ($node->hasAttributes()) {
- foreach($node->attributes as $a) {
- echo ' | '.$a->name.': '.$a->value.'<br/><hr/>';
- }
- }
- }
- ?>
- <hr/>
- <?php
- preg_match_All("#<a\s[^>]*href\s*=\s*[\'\"]??\s*?(?'path'[^\'\"\s]+?)[\'\"\s]{1}[^>]*>(?'name'[^>]*)<#simU", $content, $hrefs, PREG_SET_ORDER);
- foreach ($hrefs AS $urls){
- print $urls['path']."<br><hr/>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement