import re
import urllib2
PREFIX = "www.example.net/images/"
images = []
apat = re.compile(r'^<a.*href=["|'']([^"'']*)["|'']', re.IGNORECASE)
cpat = re.compile(r'(<[^>]*>)')
def readurl(url):
r = urllib2.urlopen(url)
s = ''
while True:
line = r.read(1024)
s += line
if len(line) < 1024:
break
return s
s = readurl(PREFIX)
l = cpat.split(s)
i = 0
while i < len(l):
if l[i].startswith('<A HREF'):
images.append(apat.match(l[i]).group(1))
i = i + 1
for i in images:
print PREFIX + i
lynx -dump "http://www.example.com/" | egrep -o "http:.*.jpg" >links.txt
<?php
$here = 'http://domain.com/folder/'; //change this to full url of your images folder
foreach(glob('*.jpg') as $image) {
echo '[img]'.$here.$image.'[/img]'; //remove the img tags if you don't need them but would be handy for forums i'm guessing
echo '<br>';
}
?>