@@ -26,100 +26,72 @@ var rule = {
2626 filterable : 0 ,
2727 timeout : 10000 ,
2828 play_parse : true ,
29- headers : {
30- 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36'
31- } ,
32- request : async function ( url , obj ) {
33- obj = obj || { } ;
34- try {
35- const response = await _fetch ( url , {
36- method : obj . method || 'GET' ,
37- headers : obj . headers || this . headers
38- } ) ;
39- return response . text ( ) ;
40- } catch ( err ) {
41- return '' ;
42- }
43- } ,
44-
29+ headers : { 'User-Agent' : 'MOBILE_UA' } ,
30+
4531 一级 : async function ( ) {
4632 let { input, pdfa, pdfh, pd} = this ;
47- let url = input . startsWith ( 'http' ) ? input : this . host + ' /book/' + input + ' /0/1.html' ;
48- let html = await this . request ( url ) ;
33+ let url = input . startsWith ( 'http' ) ? input : ` ${ this . host } /book/${ input } /0/1.html` ;
34+ let html = await request ( url ) ;
4935 let d = [ ] ;
5036 let items = pdfa ( html , '.blockcontent .c_row' ) || pdfa ( html , '.c_row' ) || [ ] ;
5137 for ( let item of items ) {
5238 let title = pdfh ( item , '.c_subject a:eq(1)&&Text' ) ;
53- let itemUrl = pd ( item , '.c_subject a:eq(1)&&href' ) ;
54- if ( ! title || ! itemUrl ) continue ;
55- let remarks = pdfh ( item , '.c_tag span:eq(1)&&Text' ) || '' ;
56- let pic = pd ( item , 'img&&src' ) || '' ;
57- let content = pdfh ( item , '.c_description&&Text' ) || '' ;
39+ let url = pd ( item , '.c_subject a:eq(1)&&href' ) ;
40+ if ( ! title || ! url ) continue ;
5841 d . push ( {
59- title : title ,
60- url : itemUrl ,
61- desc : remarks ,
62- pic_url : pic ,
63- content : content ,
42+ title,
43+ url,
44+ desc : pdfh ( item , '.c_tag span:eq(1)&&Text' ) || '' ,
45+ pic_url : pd ( item , 'img&&src' ) || '' ,
46+ content : pdfh ( item , '.c_description&&Text' ) || '' ,
6447 } ) ;
6548 }
6649 return setResult ( d ) ;
6750 } ,
6851
6952 二级 : async function ( ) {
7053 let { input, pdfa, pdfh, pd} = this ;
71- let html = await this . request ( input ) ;
72- let VOD = { } ;
73- VOD . vod_name = pdfh ( html , '[property="og:novel:book_name"]&&content' ) || '' ;
74- VOD . type_name = '' ;
75- VOD . vod_pic = pd ( html , '.divbox.cf img&&src' ) || '' ;
76- VOD . vod_content = pdfh ( html , '.tabcontent .tabvalue:eq(0)&&Text' ) || '' ;
77- VOD . vod_remarks = pdfh ( html , 'h3 a&&Text' ) || '' ;
78- VOD . vod_year = '' ;
79- VOD . vod_area = '' ;
80- VOD . vod_actor = pdfh ( html , '[property="og:novel:author"]&&content' ) || '' ;
81- VOD . vod_director = VOD . vod_actor ;
82- VOD . vod_play_from = '去读书网' ;
83- let toc_url = pd ( html , 'a:contains(点击阅读)&&href' ) || '' ;
84- if ( toc_url && ! toc_url . startsWith ( 'http' ) ) {
85- toc_url = this . host + toc_url ;
86- }
87- let toc_html = toc_url ? await this . request ( toc_url ) : '' ;
54+ let html = await request ( input ) ;
55+ let VOD = {
56+ vod_name : pdfh ( html , '[property="og:novel:book_name"]&&content' ) || '' ,
57+ vod_pic : pd ( html , '.divbox.cf img&&src' ) || '' ,
58+ vod_content : pdfh ( html , '.tabcontent .tabvalue:eq(0)&&Text' ) || '' ,
59+ vod_remarks : pdfh ( html , 'h3 a&&Text' ) || '' ,
60+ vod_actor : pdfh ( html , '[property="og:novel:author"]&&content' ) || '' ,
61+ vod_play_from : '去读书网'
62+ } ;
63+ VOD . vod_director = VOD . vod_actor ; // 复用作者信息
64+ let tocUrl = pd ( html , 'a:contains(点击阅读)&&href' ) || '' ;
65+ tocUrl = tocUrl && ! tocUrl . startsWith ( 'http' ) ? `${ this . host } ${ tocUrl } ` : tocUrl ;
66+ let tocHtml = tocUrl ? await request ( tocUrl ) : '' ;
8867 let chapters = [ ] ;
89- let chapterItems = pdfa ( toc_html , '.index li' ) || [ ] ;
90- for ( let chapter of chapterItems ) {
91- let title = pdfh ( chapter , 'a&&Text' ) ;
92- let chapter_url = pd ( chapter , 'a&&href' ) ;
93- if ( ! title || ! chapter_url ) continue ;
94- if ( ! chapter_url . startsWith ( 'http' ) ) {
95- chapter_url = this . host + chapter_url ;
96- }
97- chapters . push ( title + '$' + chapter_url ) ;
68+ let chs = pdfa ( tocHtml , '.index li' ) || [ ] ;
69+ for ( let ch of chs ) {
70+ let title = pdfh ( ch , 'a&&Text' ) ;
71+ let chUrl = pd ( ch , 'a&&href' ) ;
72+ if ( ! title || ! chUrl ) continue ;
73+ chUrl = chUrl . startsWith ( 'http' ) ? chUrl : `${ this . host } ${ chUrl } ` ;
74+ chapters . push ( `${ title } $${ chUrl } ` ) ;
9875 }
9976 VOD . vod_play_url = chapters . join ( '#' ) ;
10077 return VOD ;
10178 } ,
10279
10380 搜索 : async function ( ) {
104- let { KEY , pdfa, pdfh, pd} = this ;
105- let url = this . host + this . searchUrl . replace ( '**' , encodeURIComponent ( KEY ) ) ;
106- let html = await this . request ( url ) ;
107- if ( ! html ) {
108- url = this . host + '/modules/article/search.php?q=' + encodeURIComponent ( KEY ) ;
109- html = await this . request ( url ) ;
110- }
81+ let { input, pdfa, pdfh, pd} = this ;
82+ let html = await request ( input ) ;
11183 let d = [ ] ;
11284 let items = pdfa ( html , '#jieqi_page_contents .c_row' ) || [ ] ;
11385 for ( let item of items ) {
11486 let title = pdfh ( item , '.c_subject a&&Text' ) ;
115- let itemUrl = pd ( item , '.c_subject a&&href' ) ;
116- if ( ! title || ! itemUrl ) continue ;
117- itemUrl = itemUrl . startsWith ( 'http' ) ? itemUrl : this . host + itemUrl ;
87+ let url = pd ( item , '.c_subject a&&href' ) ;
88+ if ( ! title || ! url ) continue ;
89+ url = url . startsWith ( 'http' ) ? url : ` ${ this . host } ${ url } ` ;
11890 let pic = pd ( item , 'img&&src' ) || '' ;
119- pic = pic . startsWith ( 'http' ) ? pic : this . host + pic ;
91+ pic = pic . startsWith ( 'http' ) ? pic : ` ${ this . host } ${ pic } ` ;
12092 d . push ( {
121- title : title ,
122- url : itemUrl ,
93+ title,
94+ url,
12395 desc : pdfh ( item , '.c_tag span:eq(1)&&Text' ) || '' ,
12496 pic_url : pic ,
12597 content : '' ,
@@ -130,26 +102,28 @@ var rule = {
130102
131103 lazy : async function ( ) {
132104 let { input, pdfh} = this ;
133- let html = await this . request ( input ) ;
105+ let html = await request ( input ) ;
134106 let title = pdfh ( html , 'h1&&Text' ) || '' ;
135107 let content = pdfh ( html , '#acontent&&Html' ) || '' ;
136108 if ( content ) {
137- content = content . replace ( / < s c r i p t [ ^ > ] * ?> .* ?< \/ s c r i p t > / gs, '' )
138- . replace ( / < \/ p > / g, '\n\n' )
139- . replace ( / < b r [ ^ > ] * ?> / g, '\n' )
140- . replace ( / < [ ^ > ] * ?> / g, '' )
141- . replace ( / 去 读 书 推 荐 各 位 书 友 阅 读 : .* | 去 读 书 w w w \. q u d u s h u \. l a | 如 果 您 中 途 有 事 离 开 , 请 按 .* 以 便 以 后 接 着 观 看 ! / g, '' )
142- . replace ( / [ ( ) ] / g, '' )
143- . replace ( / & n b s p ; / g, ' ' )
144- . replace ( / [ \t ] + / g, ' ' )
145- . replace ( / \n [ \t ] + | [ \t ] + \n / g, '\n' )
146- . replace ( / \n + / g, '\n\n' )
147- . trim ( ) ;
109+ const replaceRules = [
110+ [ / < s c r i p t [ ^ > ] * ?> [ \s \S ] * ?< \/ s c r i p t > / gi, '' ] ,
111+ [ / < \/ p > | < b r \s * \/ ? > / g, '\n' ] ,
112+ [ / < [ ^ > ] * ?> / g, '' ] ,
113+ [ / 去 读 书 推 荐 各 位 书 友 阅 读 : .* | 去 读 书 w w w \. q u d u s h u \. l a | 如 果 您 中 途 有 事 离 开 , 请 按 .* 以 便 以 后 接 着 观 看 ! / g, '' ] ,
114+ [ / & n b s p ; | [ \t ] + / g, ' ' ] ,
115+ [ / \n [ \t ] * \n + / g, '\n' ]
116+ ] ;
117+ replaceRules . forEach ( ( [ reg , val ] ) => content = content . replace ( reg , val ) ) ;
118+ content = content . trim ( ) ;
119+ if ( content . startsWith ( title ) ) {
120+ content = content . replace ( title , '' ) . trim ( ) ;
121+ }
148122 }
149123 return {
150124 parse : 0 ,
151- url : ' novel://' + JSON . stringify ( { title, content} ) ,
125+ url : ` novel://${ JSON . stringify ( { title, content} ) } ` ,
152126 js : ''
153127 } ;
154128 }
155- } ;
129+ } ;
0 commit comments