Advertisement
justofeel

Untitled

Mar 21st, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2. $url ='http://www.example.com/file.html';
  3.  
  4. //<a href="http://www.example.com/file/download/idsession">download</a>
  5.  
  6. $opts = array(
  7.   'http'=>array(
  8.     'method'=>"GET",
  9.     'header'=>"Accept-language: en\r\n"
  10.   )
  11. );
  12.  
  13. $context = stream_context_create($opts);
  14.  
  15. // Open the file using the HTTP headers set above
  16. $file = file_get_contents($url, false, $context);
  17.  
  18. $filedom = new domDocument;
  19. @$filedom->loadHTML($file);
  20. $newfile = $filedom->getElementsByTagName('a');
  21.  
  22. foreach($newfile as $hrefile){
  23.     $dlurl = $hrefile->getAttribute('href');
  24.     echo $dlurl;
  25. }
  26. // Write the contents back to the file
  27. //$filename = 'example.zip';
  28. //file_put_contents($filename,$hrefile);
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement