tag:blogger.com,1999:blog-5421737826262689943.post5453036608927846008..comments2023-07-29T04:17:26.271-07:00Comments on BSD Punk: Pull the alt / title tag from xkcd picture from command linebsdpunkhttp://www.blogger.com/profile/06258196696230870045noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5421737826262689943.post-83138992650089780062011-03-14T04:19:55.303-07:002011-03-14T04:19:55.303-07:00Ack! HTML ate my regular expression. That capture ...Ack! HTML ate my regular expression. That capture named t is (?<t>...), so<br /><br />perl -MHTML::Entities -MLWP::Simple -E 'say decode_entities $+{t} if $_ = get "http://xkcd.com" and /title="(?<t>[^"]+)" alt=/'<br /><br />and<br /><br />curl -s xkcd.com | perl -MHTML::Entities -nE 'say decode_entities $+{t} if /title="(?<t>[^"]+)" alt=/'<br /><br />Sorry about that.oylenshpeegulhttps://www.blogger.com/profile/08957521303556290217noreply@blogger.comtag:blogger.com,1999:blog-5421737826262689943.post-59547390677930791132011-03-11T14:35:33.170-08:002011-03-11T14:35:33.170-08:00Nice! I just spotted this on twitter (thanks, @cli...Nice! I just spotted this on twitter (thanks, @climagic). You can ask curl not to do that progress meter with -s.<br /><br />Today, the alt text has HTML entities in it. You could use Perl to convert those<br /><br />perl -MHTML::Entities -MLWP::Simple -E 'say decode_entities $+{t} if $_ = get "http://xkcd.com" and /title="(?[^"]+)" alt=/'<br /><br />Alternatively, you could still use curl for the download<br /><br /> curl -s xkcd.com | perl -MHTML::Entities -nE 'say decode_entities $+{t} if /title="(?[^"]+)" alt=/'oylenshpeegulhttps://www.blogger.com/profile/08957521303556290217noreply@blogger.com