#!/usr/bin/perl -Imodules

#########################################
##### Author:		Sebastian Enger / B.Sc
##### CopyRight:	Sebastian Enger
##### LastModified	16.07.2006
##### Function:		
##### Todo:			
########################################

# perl -MCPAN -e 'force install "String::Approx"'
####

use Blog::PARSER::eMod;
use Blog::PARSER::Gulli;
use Blog::PARSER::BlogJunkie;
use Blog::PARSER::Allmend;
use Blog::PARSER::Golem;
use Blog::PARSER::Netzwelt;
use Blog::PARSER::NullNull;
use Blog::PARSER::FilesharingNews;
use Blog::PARSER::MP3Katalog;
# use Blog::PARSER::Heise;

use Blog::PARSER;
use Blog::SQLIO;
use Blog::HTTP;
use Blog::SQL;
use Data::Dumper;

my $DBH	= Blog::SQL->SQL();



######
###  http://www.emule-mods.cc/
######

my $pagecontent	= Blog::HTTP->GET('http://www.emule-mods.cc/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.emule-mods.cc/','(\d{2})\/(\d{4})','top');

# print Dumper($links); exit;

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::eMod->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


# eMods p2p-news

my $pagecontent	= Blog::HTTP->GET('http://www.emule-mods.cc/top/p2p-news/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.emule-mods.cc/','(\d{2})\/(\d{4})','');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::eMod->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


######
###  http://www.gulli.com/
######

### gulli filesharing

my $pagecontent	= Blog::HTTP->GET('http://www.gulli.com/filesharing/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.gulli.com/','\/news\/(\w)','filesharing');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::Gulli->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {

### gulli untergrund

my $pagecontent	= Blog::HTTP->GET('http://www.gulli.com/untergrund/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.gulli.com/','\/news\/(\w)','underground');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::Gulli->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


#### gulli news

my $pagecontent	= Blog::HTTP->GET('http://www.gulli.com/news/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.gulli.com/','\/news\/(\w)','');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::Gulli->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


######
###  http://blog-junkie.de/ Enhanced scanner
######

# BlogJunkieMainRoutine();
sub BlogJunkieMainRoutine(){

	for	(my $i=2; $i<=9; $i++){
		my $starturl = "http://blog-junkie.de/page/$i/";
		print "Scanne $starturl\n";
		BlogJunkieScanner($starturl);
	}; # for	(my $i=2; $<=110; $i++){

	sub BlogJunkieScanner(){
		
		my $url			= shift;
		my $pagecontent	= Blog::HTTP->GET($url);
		my $links		= Blog::PARSER->getLinks($pagecontent,'http://blog-junkie.de/','(\d{4})\/(\d)','(#|print)');

		foreach my $link ( @{$links} ) {
			
			my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
			if ( $status == 0 ) {
				print "Bearbeite: $link\n";
				my $page = Blog::HTTP->GET($link);
				Blog::PARSER::BlogJunkie->GrabContent($DBH, $page, $link, 'K');
			}; # if ( $status == 0 ) {

		}; # foreach my $link ( @{$links} ) {

	}; # sub NetzweltFilesharingScanner(){

}; # sub BlogJunkieMainRoutine(){


######
###  http://blog-junkie.de/
######

my $pagecontent	= Blog::HTTP->GET('http://blog-junkie.de/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://blog-junkie.de/','(\d{4})\/(\d)','(#|print)');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::BlogJunkie->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


######
###  http://blog.allmend.ch/
######

my $pagecontent	= Blog::HTTP->GET('http://blog.allmend.ch/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://blog.allmend.ch/','(\d{4})\/(\d)','#');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::Allmend->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


######
###  http://www.netzwelt.de/ Enhanced Scanner
######

# NetzweltFilesharingScannerMainRoutine();
sub NetzweltFilesharingScannerMainRoutine(){

	for	(my $i=2; $i<=50; $i++){
		my $starturl = "http://www.netzwelt.de/channel/24_$i-filesharing.html";
		print "Scanne $starturl\n";
		NetzweltFilesharingScanner($starturl);
	}; # for	(my $i=2; $<=110; $i++){


	sub NetzweltFilesharingScanner(){
		
		my $url			= shift;
		my $pagecontent	= Blog::HTTP->GET($url);
		my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.netzwelt.de/','\/news\/','#'); # /

		foreach my $link ( @{$links} ) {
			
			my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
			if ( $status == 0 ) {
				print "Bearbeite: $link\n";
				my $page = Blog::HTTP->GET($link);
				Blog::PARSER::Netzwelt->GrabContent($DBH, $page, $link, 'K');
			}; # if ( $status == 0 ) {

		}; # foreach my $link ( @{$links} ) {

	}; # sub NetzweltFilesharingScanner(){

}; # sub NetzweltFilesharingScannerMainRoutine(){


######
###  http://www.netzwelt.de/channel/24-filesharing.html
######

my $pagecontent	= Blog::HTTP->GET('http://www.netzwelt.de/channel/24-filesharing.html');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.netzwelt.de/','\/news\/','#'); # /

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::Netzwelt->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


######
###  http://www.00de.de/
######

my $pagecontent	= Blog::HTTP->GET('http://www.00de.de/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.00de.de/','(\d)\/(\d)','#');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::NullNull->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


######
### http://www.filesharing-news.de/
######

my $pagecontent	= Blog::HTTP->GET('http://www.filesharing-news.de/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.filesharing-news.de/','(\w)+\.html','#');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::FilesharingNews->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


######
### http://www.mp3-katalog.com/
######

my $pagecontent	= Blog::HTTP->GET('http://www.mp3-katalog.com/');
my $links		= Blog::PARSER->getLinks($pagecontent,'http://www.mp3-katalog.com/','artikel/+(\d)+/','#');

foreach my $link ( @{$links} ) {
	
	my $status = Blog::SQLIO->DoesLinkExists($DBH, $link);
	if ( $status == 0 ) {
		print "Bearbeite: $link\n";
		my $page = Blog::HTTP->GET($link);
		Blog::PARSER::MP3Katalog->GrabContent($DBH, $page, $link, 'K');
	}; # if ( $status == 0 ) {

}; # foreach my $link ( @{$links} ) {


######
## Close SQL Connection
######

Blog::SQL->CloseSQL($DBH);