Skip to content

Instantly share code, notes, and snippets.

@scumola
Created March 20, 2011 05:03
Show Gist options
  • Save scumola/878091 to your computer and use it in GitHub Desktop.
Save scumola/878091 to your computer and use it in GitHub Desktop.
Pulls the Original image url, title and description from a flickr description page. Doesn't download the page, but will take the html from the page on stdin.
#!/usr/bin/perl
$re1='.*?'; # Non-greedy match on filler
$re2='(?:\\/[\\w\\.\\-]+)+'; # Uninteresting: unixpath
$re3='.*?'; # Non-greedy match on filler
$re4='((?:\\/[\\w\\.\\-]+)+_o.jpg)'; # Unix Path 1
$re=$re1.$re2.$re3.$re4;
while (<STDIN>) {
$line = $_;
chop($line);
if (($line =~ m/$re/is) and ($got_orig == 0)) {
$orig_url = $1;
$got_orig = 1;
}
if (($line =~ m/<meta name="title" content="(.*)">/is) and ($got_title == 0)){
$title=$1;
$got_title = 1;
}
if (($line =~ m/<meta name="description" content="(.*)">/is) and ($got_desc == 0)){
$desc=$1;
$got_desc = 1;
}
}
print ("Original image URL: http:/$orig_url\n");
print ("Title: $title\n");
print ("Description: $desc\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment