How can I download the links (not the content in the pages that the links point to, just the links themselves. I'm trying to give a list of about 300 videos to my network admin to unblock, he just wants the URLs.

link|improve this question

80% accept rate
1  
If you were coding this, you could just use regex to pull out the link tags... – soandos Sep 13 '11 at 2:19
I'll do that, thanks. Add it as an answer to recieve credit – wizlog Sep 13 '11 at 2:46
feedback

1 Answer

up vote 2 down vote accepted

In PHP:

<?php

$webpagehtml=file_get_contents("http://www.example.com");

$dom=new DOMDocument();
$dom->loadHTML($webpagehtml);

$xpath=new DOMXPath($dom);
$items = $xpath->query("//a");

$links=array();

for ($i = 0;  $i < $items->length; $i++ ) {
$item = $items->item($i);
$title=$item->textContent;
$href=$item->getAttribute('href');

if($href && $title){
echo "$href = $title<br/>";
}
}
?>

In Python, use http://arshaw.com/scrapemark/docs/examples/.

Or you can use downthemall in firefox to do the dirty work.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.