File Coverage

blib/lib/Novel/Robot/Parser/jjwxc.pm
Criterion Covered Total %
statement 48 114 42.1
branch 1 16 6.2
condition 1 9 11.1
subroutine 10 23 43.4
pod 1 12 8.3
total 61 174 35.0


line stmt bran cond sub pod time code
1             # ABSTRACT: https://www.jjwxc.net
2              
3             =pod
4              
5             =encoding utf8
6              
7             =head1 FUNCTION
8              
9             =head2 make_query_request
10              
11             #$type:作品,作者,主角,配角,其他
12              
13             $parser->make_query_request( $type, $keyword );
14              
15             =cut
16              
17             package Novel::Robot::Parser::jjwxc;
18 2     2   12 use strict;
  2         4  
  2         54  
19 2     2   9 use warnings;
  2         4  
  2         51  
20 2     2   7 use utf8;
  2         4  
  2         10  
21 2     2   42 use base 'Novel::Robot::Parser';
  2         3  
  2         224  
22              
23 2     2   12 use Web::Scraper;
  2         4  
  2         14  
24 2     2   164 use Encode;
  2         5  
  2         214  
25 2     2   13 use Data::Dumper;
  2         4  
  2         3117  
26              
27 0     0 0 0 sub base_url { 'https://www.jjwxc.net' }
28              
29 0     0 0 0 sub domain { 'jjwxc.net' }
30              
31             sub generate_novel_url {
32 2     2 0 5 my ( $self, $index_url ) = @_;
33 2         14 my ( $novelid ) = $index_url =~ m#novelid=(\d+)#;
34 2 50       9 my $u = $novelid ? "https://m.jjwxc.net/book2/$novelid?more=0&whole=1" : $index_url;
35 2         8 return $u;
36             }
37              
38             sub parse_novel {
39 2     2 0 7 my ( $self, $h ) = @_;
40 2         180 $$h =~ s#本书霸王票读者排行.*##s;
41              
42 2         6 my %r;
43 2         22 ( $r{book} ) = $$h =~ m#\s*《(.+?)》#s; </td> </tr> <tr> <td class="h" > <a name="44">44</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="45">45</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 22 </td> <td class="s"> ($r{writer}) = $$h=~m#<li>作者:<a href="/wapauthor/\d+">(.+?)</a>#s; </td> </tr> <tr> <td class="h" > <a name="46">46</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="47">47</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 55 </td> <td class="s"> my ( $cc ) = $$h =~ m#章节列表:<br/>.+?(<a.+?)<\/div>#s; </td> </tr> <tr> <td class="h" > <a name="48">48</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 57 </td> <td class="s"> my @f = $cc =~ m#<a.+?href="(.+?/\d+/\d+.*?)".+?>(.+?)</a>#sg; </td> </tr> <tr> <td class="h" > <a name="49">49</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 15 </td> <td class="s"> my $max_chapter_num = ( $#f + 1 ) / 2; </td> </tr> <tr> <td class="h" > <a name="50">50</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 8 </td> <td class="s"> for my $i ( 1 .. $max_chapter_num ) { </td> </tr> <tr> <td class="h" > <a name="51">51</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 21 </td> <td class="s"> my $j = 2 * $i - 1; </td> </tr> <tr> <td class="h" > <a name="52">52</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 30 </td> <td class="s"> my $t = $f[$j]; </td> </tr> <tr> <td class="h" > <a name="53">53</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 38 </td> <td class="s"> $t =~ s/^\d+\.( )*//; </td> </tr> <tr> <td class="h" > <a name="54">54</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 51 </td> <td class="s"> $t =~ s/ / /g; </td> </tr> <tr> <td class="h" > <a name="55">55</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 54 </td> <td class="s"> $t =~ s/^.+>//; </td> </tr> <tr> <td class="h" > <a name="56">56</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 64 </td> <td class="s"> $t =~ s/\s+/ /g; </td> </tr> <tr> <td class="h" > <a name="57">57</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="58">58</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 20 </td> <td class="s"> my $ui = 2 * $i - 2; </td> </tr> <tr> <td class="h" > <a name="59">59</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 23 </td> <td class="s"> my $u = "https://m.jjwxc.net$f[$ui]"; </td> </tr> <tr> <td class="h" > <a name="60">60</a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 16 </td> <td class="s"> push @{ $r{item_list} }, { id => $i, title => $t, url => $u }; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 12 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 41 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="61">61</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="62">62</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="63">63</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 38 </td> <td class="s"> return \%r; </td> </tr> <tr> <td class="h" > <a name="64">64</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } ## end sub parse_novel </td> </tr> <tr> <td class="h" > <a name="65">65</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="66">66</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub parse_novel_item { </td> </tr> <tr> <td class="h" > <a name="67">67</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#67-1"> 2 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#67-1"> 0 </a> </td> <td > 8 </td> <td class="s"> my ( $self, $h ) = @_; </td> </tr> <tr> <td class="h" > <a name="68">68</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="69">69</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 233 </td> <td class="s"> my ( $c ) = $$h =~ m#<h2[^>]+>.+?<li[^>]*>(.+?)</li>#s; </td> </tr> <tr> <td class="h" > <a name="70">70</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="71">71</a> </td> <td class="c3" > 2 </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--condition.html#71-1"> 50 </a> </td> <td >   </td> <td >   </td> <td > 20 </td> <td class="s"> return { content => $c || '' }; </td> </tr> <tr> <td class="h" > <a name="72">72</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="73">73</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="74">74</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub parse_board { </td> </tr> <tr> <td class="h" > <a name="75">75</a> </td> <td class="c0" > <a href="#78"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#75-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#75-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $h ) = @_; </td> </tr> <tr> <td class="h" > <a name="76">76</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="77">77</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $parse_writer = scraper { </td> </tr> <tr> <td class="h" > <a name="78">78</a> </td> <td class="c0" > <a href="#79"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#78-1"> 0 </a> </td> <td >   </td> <td >   </td> <td class="s"> process_first '//tr[@valign="bottom"]//b', writer => 'TEXT'; </td> </tr> <tr> <td class="h" > <a name="79">79</a> </td> <td class="c0" > <a href="#80"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="80">80</a> </td> <td class="c0" > <a href="#82"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $ref = $parse_writer->scrape( $h ); </td> </tr> <tr> <td class="h" > <a name="81">81</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="82">82</a> </td> <td class="c0" > <a href="#83"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $self->tidy_string( $ref, 'writer' ); </td> </tr> <tr> <td class="h" > <a name="83">83</a> </td> <td class="c0" > <a href="#87"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return { writer => $ref->{writer} }; </td> </tr> <tr> <td class="h" > <a name="84">84</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="85">85</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="86">86</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub parse_board_item { </td> </tr> <tr> <td class="h" > <a name="87">87</a> </td> <td class="c0" > <a href="#88"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#87-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#87-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $h ) = @_; </td> </tr> <tr> <td class="h" > <a name="88">88</a> </td> <td class="c0" > <a href="#89"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my @book_list; </td> </tr> <tr> <td class="h" > <a name="89">89</a> </td> <td class="c0" > <a href="#93"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $series = '未分类'; </td> </tr> <tr> <td class="h" > <a name="90">90</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="91">91</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $parse_writer = scraper { </td> </tr> <tr> <td class="h" > <a name="92">92</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> process '//tr[@bgcolor="#eefaee"]', 'book_list[]' => sub { </td> </tr> <tr> <td class="h" > <a name="93">93</a> </td> <td class="c0" > <a href="#94"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $tr = $_[0]; </td> </tr> <tr> <td class="h" > <a name="94">94</a> </td> <td class="c0" > <a href="#96"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $series = $self->parse_writer_series_name( $tr, $series ); </td> </tr> <tr> <td class="h" > <a name="95">95</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="96">96</a> </td> <td class="c0" > <a href="#97"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $book = $self->parse_writer_book_info( $tr, $series ); </td> </tr> <tr> <td class="h" > <a name="97">97</a> </td> <td class="c0" > <a href="#98"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#97-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--condition.html#97-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> push @book_list, $book if ( $book and $book->{url} =~ /onebook/ ); </td> </tr> <tr> <td class="h" > <a name="98">98</a> </td> <td class="c0" > <a href="#99"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#98-1"> 0 </a> </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="99">99</a> </td> <td class="c0" > <a href="#101"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="100">100</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="101">101</a> </td> <td class="c0" > <a href="#103"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $ref = $parse_writer->scrape( $h ); </td> </tr> <tr> <td class="h" > <a name="102">102</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="103">103</a> </td> <td class="c0" > <a href="#104"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $self->tidy_string( $ref, 'writer' ); </td> </tr> <tr> <td class="h" > <a name="104">104</a> </td> <td class="c0" > <a href="#106"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $_->{writer} = $ref->{writer} for @book_list; </td> </tr> <tr> <td class="h" > <a name="105">105</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="106">106</a> </td> <td class="c0" > <a href="#110"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return \@book_list; </td> </tr> <tr> <td class="h" > <a name="107">107</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } ## end sub parse_board_item </td> </tr> <tr> <td class="h" > <a name="108">108</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="109">109</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub parse_writer_series_name { </td> </tr> <tr> <td class="h" > <a name="110">110</a> </td> <td class="c0" > <a href="#112"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#110-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#110-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $tr, $series ) = @_; </td> </tr> <tr> <td class="h" > <a name="111">111</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="112">112</a> </td> <td class="c0" > <a href="#114"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#112-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return $series unless ( $tr->look_down( 'colspan', '7' ) ); </td> </tr> <tr> <td class="h" > <a name="113">113</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="114">114</a> </td> <td class="c0" > <a href="#115"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#114-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if ( $tr->as_trimmed_text =~ /【(.*)】/ ) { </td> </tr> <tr> <td class="h" > <a name="115">115</a> </td> <td class="c0" > <a href="#118"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $series = $1; </td> </tr> <tr> <td class="h" > <a name="116">116</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="117">117</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="118">118</a> </td> <td class="c0" > <a href="#122"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return $series; </td> </tr> <tr> <td class="h" > <a name="119">119</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="120">120</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="121">121</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub parse_writer_book_info { </td> </tr> <tr> <td class="h" > <a name="122">122</a> </td> <td class="c0" > <a href="#124"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#122-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#122-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $tr, $series ) = @_; </td> </tr> <tr> <td class="h" > <a name="123">123</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="124">124</a> </td> <td class="c0" > <a href="#125"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $book = $tr->look_down( '_tag', 'a' ); </td> </tr> <tr> <td class="h" > <a name="125">125</a> </td> <td class="c0" > <a href="#127"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#125-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return unless ( $book ); </td> </tr> <tr> <td class="h" > <a name="126">126</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="127">127</a> </td> <td class="c0" > <a href="#129"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $book_url = $book->attr( 'href' ); </td> </tr> <tr> <td class="h" > <a name="128">128</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="129">129</a> </td> <td class="c0" > <a href="#130"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $bookname = $book->as_trimmed_text; </td> </tr> <tr> <td class="h" > <a name="130">130</a> </td> <td class="c0" > <a href="#131"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> substr( $bookname, 0, 1 ) = ''; </td> </tr> <tr> <td class="h" > <a name="131">131</a> </td> <td class="c0" > <a href="#133"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#131-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $bookname .= '[锁]' if ( $tr->look_down( 'color', 'gray' ) ); </td> </tr> <tr> <td class="h" > <a name="132">132</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="133">133</a> </td> <td class="c0" > <a href="#135"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $progress = ( $tr->look_down( '_tag', 'td' ) )[4]->as_trimmed_text; </td> </tr> <tr> <td class="h" > <a name="134">134</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return { </td> </tr> <tr> <td class="h" > <a name="135">135</a> </td> <td class="c0" > <a href="#144"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> series => $series, </td> </tr> <tr> <td class="h" > <a name="136">136</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> book => "$bookname($progress)", </td> </tr> <tr> <td class="h" > <a name="137">137</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> url => $self->base_url() . "/$book_url", </td> </tr> <tr> <td class="h" > <a name="138">138</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="139">139</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="140">140</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } ## end sub parse_writer_book_info </td> </tr> <tr> <td class="h" > <a name="141">141</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="142">142</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub make_query_request { </td> </tr> <tr> <td class="h" > <a name="143">143</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="144">144</a> </td> <td class="c0" > <a href="#145"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#144-1"> 0 </a> </td> <td class="c3" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#144-1"> 1 </a> </td> <td >   </td> <td class="s"> my ( $self, $keyword, %opt ) = @_; </td> </tr> <tr> <td class="h" > <a name="145">145</a> </td> <td class="c0" > <a href="#147"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--condition.html#145-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $opt{query_type} ||= '作品'; </td> </tr> <tr> <td class="h" > <a name="146">146</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="147">147</a> </td> <td class="c0" > <a href="#155"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my %qt = ( </td> </tr> <tr> <td class="h" > <a name="148">148</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> '作品' => '1', </td> </tr> <tr> <td class="h" > <a name="149">149</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> '作者' => '2', </td> </tr> <tr> <td class="h" > <a name="150">150</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> '主角' => '4', </td> </tr> <tr> <td class="h" > <a name="151">151</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> '配角' => '5', </td> </tr> <tr> <td class="h" > <a name="152">152</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> '其他' => '6', </td> </tr> <tr> <td class="h" > <a name="153">153</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ); </td> </tr> <tr> <td class="h" > <a name="154">154</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="155">155</a> </td> <td class="c0" > <a href="#156"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $keyword = $self->encode_cjk_for_url($keyword); </td> </tr> <tr> <td class="h" > <a name="156">156</a> </td> <td class="c0" > <a href="#159"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $url = $self->base_url() . qq[/search.php?kw=$keyword&t=$qt{$opt{query_type}}]; </td> </tr> <tr> <td class="h" > <a name="157">157</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> #$url = encode( $self->charset(), $url ); </td> </tr> <tr> <td class="h" > <a name="158">158</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="159">159</a> </td> <td class="c0" > <a href="#163"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return $url; </td> </tr> <tr> <td class="h" > <a name="160">160</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } ## end sub make_query_request </td> </tr> <tr> <td class="h" > <a name="161">161</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="162">162</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub parse_query_list { </td> </tr> <tr> <td class="h" > <a name="163">163</a> </td> <td class="c0" > <a href="#166"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#163-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#163-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $h ) = @_; </td> </tr> <tr> <td class="h" > <a name="164">164</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $parse_query = scraper { </td> </tr> <tr> <td class="h" > <a name="165">165</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> process '//div[@class="page"]/a', 'urls[]' => sub { </td> </tr> <tr> <td class="h" > <a name="166">166</a> </td> <td class="c0" > <a href="#167"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#166-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return unless ( $_[0]->as_text =~ /^\[\d*\]$/ ); </td> </tr> <tr> <td class="h" > <a name="167">167</a> </td> <td class="c0" > <a href="#168"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $url = $self->base_url() . ( $_[0]->attr( 'href' ) ); </td> </tr> <tr> <td class="h" > <a name="168">168</a> </td> <td class="c0" > <a href="#169"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $url = encode( $self->charset(), $url ); </td> </tr> <tr> <td class="h" > <a name="169">169</a> </td> <td class="c0" > <a href="#170"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return $url; </td> </tr> <tr> <td class="h" > <a name="170">170</a> </td> <td class="c0" > <a href="#171"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#170-1"> 0 </a> </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="171">171</a> </td> <td class="c0" > <a href="#172"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="172">172</a> </td> <td class="c0" > <a href="#173"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $r = $parse_query->scrape( $h ); </td> </tr> <tr> <td class="h" > <a name="173">173</a> </td> <td class="c0" > <a href="#177"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--condition.html#173-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return $r->{urls} || []; </td> </tr> <tr> <td class="h" > <a name="174">174</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } ## </td> </tr> <tr> <td class="h" > <a name="175">175</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="176">176</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub parse_query_item { </td> </tr> <tr> <td class="h" > <a name="177">177</a> </td> <td class="c0" > <a href="#180"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#177-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#177-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $h ) = @_; </td> </tr> <tr> <td class="h" > <a name="178">178</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="179">179</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $parse_query = scraper { </td> </tr> <tr> <td class="h" > <a name="180">180</a> </td> <td class="c0" > <a href="#187"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#180-1"> 0 </a> </td> <td >   </td> <td >   </td> <td class="s"> process '//h3[@class="title"]/a', </td> </tr> <tr> <td class="h" > <a name="181">181</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 'books[]' => { </td> </tr> <tr> <td class="h" > <a name="182">182</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 'book' => 'TEXT', </td> </tr> <tr> <td class="h" > <a name="183">183</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 'url' => '@href', </td> </tr> <tr> <td class="h" > <a name="184">184</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="185">185</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="186">186</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> process '//div[@class="info"]', 'writers[]' => sub { </td> </tr> <tr> <td class="h" > <a name="187">187</a> </td> <td class="c0" > <a href="#188"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my ( $writer, $progress ) = $_[0]->as_text =~ /作者:(.+?) \┃ 进度:(\S+)/s; </td> </tr> <tr> <td class="h" > <a name="188">188</a> </td> <td class="c0" > <a href="#189"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return { writer => $writer, progress => $progress }; </td> </tr> <tr> <td class="h" > <a name="189">189</a> </td> <td class="c0" > <a href="#190"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="190">190</a> </td> <td class="c0" > <a href="#191"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="191">191</a> </td> <td class="c0" > <a href="#193"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $ref = $parse_query->scrape( $h ); </td> </tr> <tr> <td class="h" > <a name="192">192</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="193">193</a> </td> <td class="c0" > <a href="#194"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my @result; </td> </tr> <tr> <td class="h" > <a name="194">194</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> foreach my $i ( 0 .. $#{ $ref->{books} } ) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#195"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="195">195</a> </td> <td class="c0" > <a href="#196"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $r = $ref->{books}[$i]; </td> </tr> <tr> <td class="h" > <a name="196">196</a> </td> <td class="c0" > <a href="#198"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#196-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> next unless ( $r->{url} ); </td> </tr> <tr> <td class="h" > <a name="197">197</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="198">198</a> </td> <td class="c0" > <a href="#199"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $w = $ref->{writers}[$i]; </td> </tr> <tr> <td class="h" > <a name="199">199</a> </td> <td class="c0" > <a href="#200"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $r->{title} .= "($w->{progress})"; </td> </tr> <tr> <td class="h" > <a name="200">200</a> </td> <td class="c0" > <a href="#203"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> push @result, { %$w, %$r }; </td> </tr> <tr> <td class="h" > <a name="201">201</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="202">202</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="203">203</a> </td> <td class="c0" > 0 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return \@result; </td> </tr> <tr> <td class="h" > <a name="204">204</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } ## end sub parse_query_item </td> </tr> <tr> <td class="h" > <a name="205">205</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="206">206</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 1; </td> </tr> </table> </body> </html>