File Coverage

blib/lib/Novel/Robot/Parser/jjwxc.pm
Criterion Covered Total %
statement 47 113 41.5
branch 1 16 6.2
condition 1 9 11.1
subroutine 10 23 43.4
pod 1 12 8.3
total 60 173 34.6


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 1     1   6 use strict;
  1         2  
  1         31  
19 1     1   5 use warnings;
  1         2  
  1         23  
20 1     1   5 use utf8;
  1         2  
  1         6  
21 1     1   23 use base 'Novel::Robot::Parser';
  1         3  
  1         109  
22              
23 1     1   7 use Web::Scraper;
  1         2  
  1         12  
24 1     1   103 use Encode;
  1         2  
  1         115  
25 1     1   7 use Data::Dumper;
  1         2  
  1         1829  
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 1     1 0 3 my ( $self, $index_url ) = @_;
33 1         6 my ( $novelid ) = $index_url =~ m#novelid=(\d+)#;
34 1 50       5 my $u = $novelid ? "https://m.jjwxc.net/book2/$novelid?more=0&whole=1" : $index_url;
35 1         4 return $u;
36             }
37              
38             sub parse_novel {
39 1     1 0 4 my ( $self, $h ) = @_;
40 1         129 $$h =~ s#本书霸王票读者排行.*##s;
41              
42 1         3 my %r;
43 1         14 ( $r{book}, $r{writer} ) = $$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" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 47 </td> <td class="s"> my ( $cc ) = $$h =~ m#章节列表:<br/>.+?(<a.+?)<\/div>#s; </td> </tr> <tr> <td class="h" > <a name="46">46</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 48 </td> <td class="s"> my @f = $cc =~ m#<a.+?href="(.+?/\d+/\d+.*?)".+?>(.+?)</a>#sg; </td> </tr> <tr> <td class="h" > <a name="47">47</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> my $max_chapter_num = ( $#f + 1 ) / 2; </td> </tr> <tr> <td class="h" > <a name="48">48</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> for my $i ( 1 .. $max_chapter_num ) { </td> </tr> <tr> <td class="h" > <a name="49">49</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 19 </td> <td class="s"> my $j = 2 * $i - 1; </td> </tr> <tr> <td class="h" > <a name="50">50</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 16 </td> <td class="s"> my $t = $f[$j]; </td> </tr> <tr> <td class="h" > <a name="51">51</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 51 </td> <td class="s"> $t =~ s/^\d+\.( )*//; </td> </tr> <tr> <td class="h" > <a name="52">52</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 46 </td> <td class="s"> $t =~ s/ / /g; </td> </tr> <tr> <td class="h" > <a name="53">53</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 56 </td> <td class="s"> $t =~ s/^.+>//; </td> </tr> <tr> <td class="h" > <a name="54">54</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 57 </td> <td class="s"> $t =~ s/\s+/ /g; </td> </tr> <tr> <td class="h" > <a name="55">55</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="56">56</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 18 </td> <td class="s"> my $ui = 2 * $i - 2; </td> </tr> <tr> <td class="h" > <a name="57">57</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 20 </td> <td class="s"> my $u = "https://m.jjwxc.net$f[$ui]"; </td> </tr> <tr> <td class="h" > <a name="58">58</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 15 </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" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 41 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="59">59</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="60">60</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="61">61</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 9 </td> <td class="s"> return \%r; </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"> } ## end sub parse_novel </td> </tr> <tr> <td class="h" > <a name="63">63</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="64">64</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="65">65</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#65-1"> 1 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#65-1"> 0 </a> </td> <td > 4 </td> <td class="s"> my ( $self, $h ) = @_; </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">   </td> </tr> <tr> <td class="h" > <a name="67">67</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 174 </td> <td class="s"> my ( $c ) = $$h =~ m#<h2[^>]+>.+?<li[^>]*>(.+?)</li>#s; </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" > 1 </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--condition.html#69-1"> 50 </a> </td> <td >   </td> <td >   </td> <td > 18 </td> <td class="s"> return { content => $c || '' }; </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 >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </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"> sub parse_board { </td> </tr> <tr> <td class="h" > <a name="73">73</a> </td> <td class="c0" > <a href="#76"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#73-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#73-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $h ) = @_; </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">   </td> </tr> <tr> <td class="h" > <a name="75">75</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="76">76</a> </td> <td class="c0" > <a href="#77"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#76-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="77">77</a> </td> <td class="c0" > <a href="#78"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="78">78</a> </td> <td class="c0" > <a href="#80"> 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="79">79</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="80">80</a> </td> <td class="c0" > <a href="#81"> 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="81">81</a> </td> <td class="c0" > <a href="#85"> 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="82">82</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="83">83</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="84">84</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="85">85</a> </td> <td class="c0" > <a href="#86"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#85-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#85-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $h ) = @_; </td> </tr> <tr> <td class="h" > <a name="86">86</a> </td> <td class="c0" > <a href="#87"> 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="87">87</a> </td> <td class="c0" > <a href="#91"> 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="88">88</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="89">89</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="90">90</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="91">91</a> </td> <td class="c0" > <a href="#92"> 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="92">92</a> </td> <td class="c0" > <a href="#94"> 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="93">93</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="94">94</a> </td> <td class="c0" > <a href="#95"> 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="95">95</a> </td> <td class="c0" > <a href="#96"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#95-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--condition.html#95-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="96">96</a> </td> <td class="c0" > <a href="#97"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#96-1"> 0 </a> </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="97">97</a> </td> <td class="c0" > <a href="#99"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="98">98</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="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"> my $ref = $parse_writer->scrape( $h ); </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="#102"> 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="102">102</a> </td> <td class="c0" > <a href="#104"> 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="103">103</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="104">104</a> </td> <td class="c0" > <a href="#108"> 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="105">105</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="106">106</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="107">107</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="108">108</a> </td> <td class="c0" > <a href="#110"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#108-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#108-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $tr, $series ) = @_; </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">   </td> </tr> <tr> <td class="h" > <a name="110">110</a> </td> <td class="c0" > <a href="#112"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#110-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="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="#113"> 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"> if ( $tr->as_trimmed_text =~ /【(.*)】/ ) { </td> </tr> <tr> <td class="h" > <a name="113">113</a> </td> <td class="c0" > <a href="#116"> 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="114">114</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="115">115</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="116">116</a> </td> <td class="c0" > <a href="#120"> 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="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 >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </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"> sub parse_writer_book_info { </td> </tr> <tr> <td class="h" > <a name="120">120</a> </td> <td class="c0" > <a href="#122"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#120-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#120-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $tr, $series ) = @_; </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">   </td> </tr> <tr> <td class="h" > <a name="122">122</a> </td> <td class="c0" > <a href="#123"> 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="123">123</a> </td> <td class="c0" > <a href="#125"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#123-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="124">124</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="125">125</a> </td> <td class="c0" > <a href="#127"> 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="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="#128"> 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="128">128</a> </td> <td class="c0" > <a href="#129"> 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="129">129</a> </td> <td class="c0" > <a href="#131"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#129-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="130">130</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="131">131</a> </td> <td class="c0" > <a href="#133"> 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="132">132</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="133">133</a> </td> <td class="c0" > <a href="#142"> 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="134">134</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="135">135</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="136">136</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="137">137</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="138">138</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="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"> sub make_query_request { </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 class="c0" > <a href="#143"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#142-1"> 0 </a> </td> <td class="c3" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#142-1"> 1 </a> </td> <td >   </td> <td class="s"> my ( $self, $keyword, %opt ) = @_; </td> </tr> <tr> <td class="h" > <a name="143">143</a> </td> <td class="c0" > <a href="#145"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--condition.html#143-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $opt{query_type} ||= '作品'; </td> </tr> <tr> <td class="h" > <a name="144">144</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="145">145</a> </td> <td class="c0" > <a href="#153"> 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="146">146</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="147">147</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="148">148</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="149">149</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="150">150</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="151">151</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="152">152</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="153">153</a> </td> <td class="c0" > <a href="#154"> 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="154">154</a> </td> <td class="c0" > <a href="#157"> 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="155">155</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="156">156</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="157">157</a> </td> <td class="c0" > <a href="#161"> 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="158">158</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="159">159</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="160">160</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="161">161</a> </td> <td class="c0" > <a href="#164"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#161-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#161-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $h ) = @_; </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"> my $parse_query = scraper { </td> </tr> <tr> <td class="h" > <a name="163">163</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="164">164</a> </td> <td class="c0" > <a href="#165"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#164-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="165">165</a> </td> <td class="c0" > <a href="#166"> 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="166">166</a> </td> <td class="c0" > <a href="#167"> 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="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"> return $url; </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 class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#168-1"> 0 </a> </td> <td >   </td> <td >   </td> <td class="s"> }; </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"> }; </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 >   </td> <td >   </td> <td >   </td> <td class="s"> my $r = $parse_query->scrape( $h ); </td> </tr> <tr> <td class="h" > <a name="171">171</a> </td> <td class="c0" > <a href="#175"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--condition.html#171-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return $r->{urls} || []; </td> </tr> <tr> <td class="h" > <a name="172">172</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="173">173</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="174">174</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="175">175</a> </td> <td class="c0" > <a href="#178"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#175-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#175-1"> 0 </a> </td> <td >   </td> <td class="s"> my ( $self, $h ) = @_; </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">   </td> </tr> <tr> <td class="h" > <a name="177">177</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="178">178</a> </td> <td class="c0" > <a href="#185"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--subroutine.html#178-1"> 0 </a> </td> <td >   </td> <td >   </td> <td class="s"> process '//h3[@class="title"]/a', </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"> 'books[]' => { </td> </tr> <tr> <td class="h" > <a name="180">180</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="181">181</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="182">182</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="183">183</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="184">184</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="185">185</a> </td> <td class="c0" > <a href="#186"> 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="186">186</a> </td> <td class="c0" > <a href="#187"> 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="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"> }; </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"> }; </td> </tr> <tr> <td class="h" > <a name="189">189</a> </td> <td class="c0" > <a href="#191"> 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="190">190</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="191">191</a> </td> <td class="c0" > <a href="#192"> 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="192">192</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="#193"> 0 </a> </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 $r = $ref->{books}[$i]; </td> </tr> <tr> <td class="h" > <a name="194">194</a> </td> <td class="c0" > <a href="#196"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Novel-Robot-Parser-jjwxc-pm--branch.html#194-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="195">195</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="196">196</a> </td> <td class="c0" > <a href="#197"> 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="197">197</a> </td> <td class="c0" > <a href="#198"> 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="198">198</a> </td> <td class="c0" > <a href="#201"> 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="199">199</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="200">200</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="201">201</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="202">202</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="203">203</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="204">204</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 1; </td> </tr> </table> </body> </html>