Quote:
Originally posted by garett
Here's a little script I wrote for you:
Code:
<?php
header("Content-type: text/plain");
$f = file_get_contents("http://path_to_gallery_html", "r");
$file = strtolower($f);
$lines = split("\n", $file);
foreach($lines as $line) {
if(preg_match("/href=[\"|\']([^\"|\']+.jpg)|([^\"|\']+.jpeg)/", $line, $matches)) {
echo $matches[1] . "\n";
}
}
?>
I prefer to do it on a line per line basis.. and I also converted the entire HTML to lower case so you don't have to test for file names that are upper case.
cheers
Edit: I just realized a little more explanation might be needed about the pattern..
First off .. a lot of people form their link tags like <a href='http://blahblah' .. single quotes rather than double quotes.. so it's a good idea to check for both.
And then also you need to check for '.jpg' and '.jpeg' respectively ..
|
your code assumes there is at most 1 image url per line, and the regular expression has redundant code.
correct me if i'm wrong.