This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
use Gumbo; | |
use XML; | |
use HTTP::UserAgent; | |
#We define some base url, notice that I don't use https | |
my $bbaseurl = "http://www.fimfiction.net/bookshelf/"; | |
my $fimbaseurl = "http://www.fimfiction.net/"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
use lib './', '/root/testmodif/s/perl6-html-parser-xml/lib/'; | |
use FicClass; | |
use Gumbo; | |
use StoryFactory; | |
use HTTP::UserAgent; | |
use HTTP::Cookie; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Gumbo::Parser; # replace with HTML::Parser::XML | |
use XML; | |
my $parser = Gumbo::Parser.new; | |
my $html = qqx{wget -o /dev/null -O - https://www.fimfiction.net/bookshelf/149291/}; | |
say "Getting/parsing a wegpage with a quite huge xml tree, prepare yourself some coffee if you use H:P:X"; | |
say "webpage is "~$html.chars~" size."; | |
my $xml = $parser.parse($html); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Config::Simple::Role; | |
class Config::Simple does Config::Simple::Role { | |
multi method new($filename) { | |
return self.bless(:filename($filename)); | |
} | |
multi method new($filename, Str :$b) { | |
my $module = "Config::Simple::$b"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub get_bookshelf { | |
my $rep = $ua.get("$bbaseurl$bookid"); | |
if ! $rep.is-success { | |
die "Can't contact $bbaseurl"; | |
} | |
# first we need to know the number of page | |
my $xmldoc = parse-html($rep.content, :TAG<div>, :class<page_list>, :SINGLE, :nowhitespace); | |
my @pages = $xmldoc.elements(:TAG<li>, :RECURSE); | |
my $number_of_page; |
NewerOlder