#!/usr/bin/perl -w use strict; use XML::RSS; use LWP::Simple; #my $testpage = "https://www.thesun.co.uk/article/0,,13-2004480024,00.html"; my $toppage = get('https://www.thesun.co.uk/section/0,,1,00.html'); my $page; my $pageurl; my $rss = new XML::RSS (version => '1.0'); if ($toppage =~ m!(/article/0,,13[^"']*)!) { $pageurl = "https://www.thesun.co.uk" . $1; } if (!$pageurl) { exit -1; } $page = get($pageurl); $rss->channel(title => 'The Sun: Viral Emails', link => $pageurl, description => 'The Sun: Viral Emails'); my @lines = split ("<[tT][Rr]", $page); foreach (@lines) { if (m!'(/popupWindow/0,,13[^"']*)', \d+, \d+, 'email\d+'\);">([^<]*)!i) { $rss->add_item(title => "$2", link => 'https://www.thesun.co.uk' . $1, description => "$pageurl"); } } print $rss->as_string;