parent
abe39c5eb9
commit
cf8f5b797f
@ -1,105 +0,0 @@ |
||||
package xyz.fycz.myreader.entity; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
|
||||
|
||||
|
||||
public class JsonModel implements Serializable { |
||||
|
||||
private static final long serialVersionUID = -7169864463597942730L; |
||||
|
||||
private int error;//错误码
|
||||
private boolean success;//请求是否成功
|
||||
private String result;//服务器返回的json数据存放与此
|
||||
private String token; |
||||
private int datasize; |
||||
private String publicKey; |
||||
|
||||
|
||||
private int visibleLastIndex = 0; |
||||
private int visibleItemCount; |
||||
|
||||
|
||||
public JsonModel() { |
||||
|
||||
} |
||||
|
||||
public String getPublicKey() { |
||||
return publicKey; |
||||
} |
||||
|
||||
public void setPublicKey(String publicKey) { |
||||
this.publicKey = publicKey; |
||||
} |
||||
|
||||
public int getError() { |
||||
return this.error; |
||||
} |
||||
|
||||
public void setError(int error) { |
||||
this.error = error; |
||||
} |
||||
|
||||
public String getResult() { |
||||
return this.result; |
||||
} |
||||
|
||||
public void setResult(String result) { |
||||
this.result = result; |
||||
} |
||||
|
||||
public String getToken() { |
||||
return this.token; |
||||
} |
||||
|
||||
public void setToken(String token) { |
||||
this.token = token; |
||||
} |
||||
|
||||
public boolean isSuccess() { |
||||
return this.success; |
||||
} |
||||
|
||||
public void setSuccess(boolean success) { |
||||
this.success = success; |
||||
} |
||||
|
||||
public int getVisibleLastIndex() { |
||||
return this.visibleLastIndex; |
||||
} |
||||
|
||||
public void setVisibleLastIndex(int visibleLastIndex) { |
||||
this.visibleLastIndex = visibleLastIndex; |
||||
} |
||||
|
||||
public int getVisibleItemCount() { |
||||
return this.visibleItemCount; |
||||
} |
||||
|
||||
public void setVisibleItemCount(int visibleItemCount) { |
||||
this.visibleItemCount = visibleItemCount; |
||||
} |
||||
|
||||
public int getDatasize() { |
||||
return this.datasize; |
||||
} |
||||
|
||||
public void setDatasize(int datasize) { |
||||
this.datasize = datasize; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "JsonModel{" + |
||||
"error=" + error + |
||||
", success=" + success + |
||||
", result='" + result + '\'' + |
||||
", token='" + token + '\'' + |
||||
", datasize=" + datasize + |
||||
", visibleLastIndex=" + visibleLastIndex + |
||||
", visibleItemCount=" + visibleItemCount + |
||||
'}'; |
||||
} |
||||
} |
@ -1,35 +0,0 @@ |
||||
package xyz.fycz.myreader.enums; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
public enum FindType implements Serializable { |
||||
|
||||
qidian("排行榜[起点中文网]", "https://www.qidian.com/rank"), |
||||
qidianns("排行榜[起点女生网]", "https://www.qidian.com/mm/rank"), |
||||
qb5("书城[全本小说]", "https://www.qb5.tw"), |
||||
biquge("书城[笔趣阁]", "https://www.52bqg.com"); |
||||
private String text; |
||||
private String url; |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
FindType(String text, String url) { |
||||
this.text = text; |
||||
this.url = url; |
||||
} |
||||
|
||||
public static FindType get(int var0) { |
||||
return values()[var0]; |
||||
} |
||||
|
||||
public static FindType fromString(String string) { |
||||
return valueOf(string); |
||||
} |
||||
|
||||
public String getText() { |
||||
return text; |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url; |
||||
} |
||||
} |
@ -1,22 +0,0 @@ |
||||
package xyz.fycz.myreader.enums; |
||||
|
||||
public enum ReadStyle { |
||||
|
||||
protectedEye,//护眼
|
||||
common,//普通
|
||||
blueDeep,//深蓝
|
||||
leather,//羊皮纸
|
||||
breen,//
|
||||
custom; |
||||
|
||||
ReadStyle() { |
||||
} |
||||
|
||||
public static ReadStyle get(int var0) { |
||||
return values()[var0]; |
||||
} |
||||
|
||||
public static ReadStyle fromString(String string) { |
||||
return ReadStyle.valueOf(string); |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package xyz.fycz.myreader.webapi.crawler.base; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author fengyue |
||||
* @date 2021/5/13 22:29 |
||||
*/ |
||||
public abstract class BaseLocalCrawler implements ReadCrawler { |
||||
@Override |
||||
public Map<String, String> getHeaders() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,179 @@ |
||||
package xyz.fycz.myreader.webapi.crawler.find; |
||||
|
||||
import android.text.Html; |
||||
|
||||
import org.jsoup.Jsoup; |
||||
import org.jsoup.nodes.Document; |
||||
import org.jsoup.nodes.Element; |
||||
import org.jsoup.select.Elements; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.LinkedHashMap; |
||||
import java.util.List; |
||||
|
||||
import xyz.fycz.myreader.entity.SearchBookBean; |
||||
import xyz.fycz.myreader.entity.bookstore.BookType; |
||||
import xyz.fycz.myreader.enums.LocalBookSource; |
||||
import xyz.fycz.myreader.greendao.entity.Book; |
||||
import xyz.fycz.myreader.greendao.entity.Chapter; |
||||
import xyz.fycz.myreader.model.mulvalmap.ConcurrentMultiValueMap; |
||||
import xyz.fycz.myreader.webapi.crawler.base.BookInfoCrawler; |
||||
import xyz.fycz.myreader.webapi.crawler.base.FindCrawler; |
||||
import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; |
||||
|
||||
@Deprecated |
||||
public class Ben100FindCrawler extends FindCrawler { |
||||
public static final String NAME_SPACE = "https://www.100ben.net"; |
||||
public static final String CHARSET = "UTF-8"; |
||||
public static final String SEARCH_CHARSET = "utf-8"; |
||||
public static final String FIND_NAME = "书城[100本书·实体]"; |
||||
private LinkedHashMap<String, String> mBookTypes = new LinkedHashMap<>(); |
||||
|
||||
@Override |
||||
public String getCharset() { |
||||
return CHARSET; |
||||
} |
||||
|
||||
@Override |
||||
public String getFindName() { |
||||
return FIND_NAME; |
||||
} |
||||
|
||||
@Override |
||||
public String getFindUrl() { |
||||
return NAME_SPACE; |
||||
} |
||||
|
||||
@Override |
||||
public boolean hasImg() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public boolean needSearch() { |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* 获取书籍详细信息 |
||||
* |
||||
* @param book |
||||
*/ |
||||
public Book getBookInfo(String html, Book book) { |
||||
Document doc = Jsoup.parse(html); |
||||
Element img = doc.getElementById("fmimg"); |
||||
book.setImgUrl(img.getElementsByTag("img").get(0).attr("src")); |
||||
Element desc = doc.getElementById("intro"); |
||||
book.setDesc(desc.getElementsByTag("p").get(0).text()); |
||||
Element type = doc.getElementsByClass("con_top").get(0); |
||||
book.setType(type.getElementsByTag("a").get(2).text()); |
||||
return book; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public List<BookType> getBookTypes(String html) { |
||||
List<BookType> bookTypes = new ArrayList<>(); |
||||
Document doc = Jsoup.parse(html); |
||||
Element menu = doc.getElementsByClass("menu").first(); |
||||
for (Element a : menu.children()) { |
||||
String name = a.text(); |
||||
String url = a.attr("href"); |
||||
if ("首页".equals(name)) { |
||||
name = "100本书"; |
||||
} else if (name.contains("全部小说")) { |
||||
name = "全部小说"; |
||||
} |
||||
BookType bookType = new BookType(); |
||||
bookType.setTypeName(name); |
||||
bookType.setUrl(url); |
||||
bookTypes.add(bookType); |
||||
System.out.println("bookTypes.put(\"" + bookType.getTypeName() + "\", \"" + bookType.getUrl() + "\");"); |
||||
} |
||||
return bookTypes; |
||||
} |
||||
|
||||
@Override |
||||
public List<BookType> getBookTypes() { |
||||
initBookTypes(); |
||||
List<BookType> bookTypes = new ArrayList<>(); |
||||
for (String name : mBookTypes.keySet()) { |
||||
BookType bookType = new BookType(); |
||||
bookType.setTypeName(name); |
||||
bookType.setUrl(mBookTypes.get(name)); |
||||
bookTypes.add(bookType); |
||||
} |
||||
return bookTypes; |
||||
} |
||||
|
||||
private void initBookTypes() { |
||||
mBookTypes.put("世界名著", "https://www.100ben.net/shijiemingzhu/"); |
||||
mBookTypes.put("现代文学", "https://www.100ben.net/xiandaiwenxue/"); |
||||
mBookTypes.put("外国小说", "https://www.100ben.net/waiguoxiaoshuo/"); |
||||
mBookTypes.put("励志书籍", "https://www.100ben.net/lizhishuji/"); |
||||
mBookTypes.put("古典文学", "https://www.100ben.net/gudianwenxue/"); |
||||
mBookTypes.put("武侠小说", "https://www.100ben.net/wuxiaxiaoshuo/"); |
||||
mBookTypes.put("言情小说", "https://www.100ben.net/yanqingxiaoshuo/"); |
||||
mBookTypes.put("推理小说", "https://www.100ben.net/tuilixiaoshuo/"); |
||||
mBookTypes.put("科幻小说", "https://www.100ben.net/kehuanxiaoshuo/"); |
||||
mBookTypes.put("人物传记", "https://www.100ben.net/renwuzhuanji/"); |
||||
mBookTypes.put("盗墓悬疑", "https://www.100ben.net/daomuxuanyi/"); |
||||
mBookTypes.put("玄幻穿越", "https://www.100ben.net/xuanhuanchuanyue/"); |
||||
mBookTypes.put("科普书籍", "https://www.100ben.net/kepushuji/"); |
||||
mBookTypes.put("100本书", "https://www.100ben.net/"); |
||||
mBookTypes.put("全部小说", "https://www.100ben.net/all/"); |
||||
} |
||||
|
||||
@Override |
||||
public List<Book> getFindBooks(String html, BookType bookType) { |
||||
List<Book> books = new ArrayList<>(); |
||||
Document doc = Jsoup.parse(html); |
||||
|
||||
try { |
||||
Element pageDiv = doc.getElementsByClass("page").first(); |
||||
String page = pageDiv.getElementsByTag("a").last().text(); |
||||
String pageStr = page.replace("末页(", "").replace(")", ""); |
||||
bookType.setPageSize(Integer.parseInt(pageStr)); |
||||
} catch (Exception ignored) { |
||||
} |
||||
|
||||
Elements divs = doc.getElementsByClass("recommand"); |
||||
Element div = divs.get(0); |
||||
Elements elementsByTag = div.getElementsByTag("li"); |
||||
for (Element element : elementsByTag) { |
||||
Book book = new Book(); |
||||
String name = element.getElementsByClass("titles").first().getElementsByTag("a").first().text(); |
||||
book.setName(name); |
||||
String author = element.getElementsByClass("author").first().text().replace("作者:", ""); |
||||
book.setAuthor(author); |
||||
String imgUrl = element.getElementsByTag("img").first().attr("src"); |
||||
book.setImgUrl(imgUrl); |
||||
String chapterUrl = element.getElementsByClass("titles").first().getElementsByTag("a").first().attr("href"); |
||||
book.setChapterUrl(chapterUrl); |
||||
String desc = element.getElementsByClass("intro").first().text(); |
||||
book.setDesc(desc); |
||||
book.setNewestChapterTitle(""); |
||||
book.setType(bookType.getTypeName()); |
||||
book.setSource(LocalBookSource.ben100.toString()); |
||||
books.add(book); |
||||
} |
||||
return books; |
||||
} |
||||
|
||||
@Override |
||||
public boolean getTypePage(BookType curType, int page) { |
||||
if (curType.getPageSize() <= 0) { |
||||
curType.setPageSize(1); |
||||
} |
||||
if (page > curType.getPageSize()) { |
||||
return true; |
||||
} |
||||
if (curType.getTypeName().equals("100本书")) return false; |
||||
if (curType.getUrl().contains("list")) { |
||||
curType.setUrl(curType.getUrl().substring(0, curType.getUrl().lastIndexOf("_") + 1) + page + ".html"); |
||||
} else { |
||||
curType.setUrl(curType.getUrl() + "list_" + page + ".html"); |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,119 @@ |
||||
package xyz.fycz.myreader.webapi.crawler.find; |
||||
|
||||
import android.text.Html; |
||||
|
||||
import org.jsoup.Jsoup; |
||||
import org.jsoup.nodes.Document; |
||||
import org.jsoup.nodes.Element; |
||||
import org.jsoup.select.Elements; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.LinkedHashMap; |
||||
import java.util.List; |
||||
|
||||
import xyz.fycz.myreader.entity.SearchBookBean; |
||||
import xyz.fycz.myreader.entity.bookstore.BookType; |
||||
import xyz.fycz.myreader.enums.LocalBookSource; |
||||
import xyz.fycz.myreader.greendao.entity.Book; |
||||
import xyz.fycz.myreader.greendao.entity.Chapter; |
||||
import xyz.fycz.myreader.model.mulvalmap.ConcurrentMultiValueMap; |
||||
import xyz.fycz.myreader.webapi.crawler.base.FindCrawler; |
||||
import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; |
||||
|
||||
|
||||
public class MiaoBiFindCrawler extends FindCrawler { |
||||
public static final String NAME_SPACE = "https://www.imiaobige.com"; |
||||
public static final String CHARSET = "UTF-8"; |
||||
public static final String SEARCH_CHARSET = "UTF-8"; |
||||
public static final String FIND_NAME = "书城[妙笔阁]"; |
||||
private final LinkedHashMap<String, String> mBookTypes = new LinkedHashMap<>(); |
||||
|
||||
@Override |
||||
public String getCharset() { |
||||
return CHARSET; |
||||
} |
||||
|
||||
@Override |
||||
public String getFindName() { |
||||
return FIND_NAME; |
||||
} |
||||
|
||||
@Override |
||||
public String getFindUrl() { |
||||
return NAME_SPACE; |
||||
} |
||||
|
||||
@Override |
||||
public boolean hasImg() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public boolean needSearch() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public List<BookType> getBookTypes() { |
||||
initBookTypes(); |
||||
List<BookType> bookTypes = new ArrayList<>(); |
||||
for (String name : mBookTypes.keySet()) { |
||||
BookType bookType = new BookType(); |
||||
bookType.setTypeName(name); |
||||
bookType.setUrl(mBookTypes.get(name)); |
||||
bookType.setPageSize(100); |
||||
bookTypes.add(bookType); |
||||
} |
||||
return bookTypes; |
||||
} |
||||
|
||||
private void initBookTypes() { |
||||
mBookTypes.put("玄幻奇幻", "https://www.imiaobige.com/xuanhuan/1.html"); |
||||
mBookTypes.put("武侠仙侠", "https://www.imiaobige.com/wuxia/1.html"); |
||||
mBookTypes.put("都市生活", "https://www.imiaobige.com/dushi/1.html"); |
||||
mBookTypes.put("历史军事", "https://www.imiaobige.com/lishi/1.html"); |
||||
mBookTypes.put("游戏竞技", "https://www.imiaobige.com/youxi/1.html"); |
||||
mBookTypes.put("科幻未来", "https://www.imiaobige.com/kehuan/1.html"); |
||||
} |
||||
|
||||
/* |
||||
<dl> |
||||
<dt><a href="/novel/225809.html"><img src="https://img.imiaobige.com/225809/1177644.jpg" alt="重生之我变成了火星" height="155" width="120"></a></dt> |
||||
<dd><span class="uptime">20-11-26 16:57</span><a href="/novel/225809.html"><h3>重生之我变成了火星</h3></a></dd> |
||||
<dd class="book_other">作者:<a href="/author/仰望黑夜/">仰望黑夜</a>状态:<span>连载中</span></dd> |
||||
<dd class="book_des">重生成了火星?第一阶段科技进化,第二阶段高魔进化,第三阶段超魔进化!宇宙之间除了人类还有无数可怕存在,让我带领人类征服宇宙,我们的目标是星辰大海~</dd> |
||||
<dd class="book_other">最新章节:<a href="/read/225809/863539.html">第三百一十六章 时空道兵</a></dd> |
||||
</dl> |
||||
*/ |
||||
@Override |
||||
public List<Book> getFindBooks(String html, BookType bookType) { |
||||
List<Book> books = new ArrayList<>(); |
||||
Document doc = Jsoup.parse(html); |
||||
Element div = doc.getElementById("sitebox"); |
||||
Elements dls = div.getElementsByTag("dl"); |
||||
for (Element dl : dls) { |
||||
Book book = new Book(); |
||||
Elements as = dl.getElementsByTag("a"); |
||||
book.setName(as.get(1).text()); |
||||
book.setAuthor(as.get(2).text()); |
||||
book.setType(bookType.getTypeName()); |
||||
book.setNewestChapterTitle(as.get(3).text()); |
||||
book.setDesc(dl.getElementsByClass("book_des").first().text()); |
||||
book.setImgUrl(as.first().getElementsByTag("img").attr("src")); |
||||
book.setChapterUrl(as.get(1).attr("href").replace("novel", "read").replace(".html", "/")); |
||||
book.setUpdateDate(dl.getElementsByClass("uptime").first().text()); |
||||
book.setSource(LocalBookSource.miaobi.toString()); |
||||
books.add(book); |
||||
} |
||||
return books; |
||||
} |
||||
|
||||
@Override |
||||
public boolean getTypePage(BookType curType, int page) { |
||||
if (page > curType.getPageSize()) { |
||||
return true; |
||||
} |
||||
curType.setUrl(curType.getUrl().substring(0, curType.getUrl().lastIndexOf("/") + 1) + page + ".html"); |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,158 @@ |
||||
package xyz.fycz.myreader.webapi.crawler.find; |
||||
|
||||
import org.jsoup.Jsoup; |
||||
import org.jsoup.nodes.Document; |
||||
import org.jsoup.nodes.Element; |
||||
import org.jsoup.select.Elements; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import xyz.fycz.myreader.entity.bookstore.BookType; |
||||
import xyz.fycz.myreader.enums.LocalBookSource; |
||||
import xyz.fycz.myreader.greendao.entity.Book; |
||||
import xyz.fycz.myreader.util.StringHelper; |
||||
import xyz.fycz.myreader.webapi.crawler.base.FindCrawler; |
||||
|
||||
|
||||
public class QB5FindCrawler extends FindCrawler { |
||||
public static final String FIND_URL = "https://www.qb50.com"; |
||||
public static final String FIND_NAME = "书城[全本小说]"; |
||||
private static final String CHARSET = "GBK"; |
||||
|
||||
@Override |
||||
public String getCharset() { |
||||
return CHARSET; |
||||
} |
||||
|
||||
@Override |
||||
public String getFindName() { |
||||
return FIND_NAME; |
||||
} |
||||
|
||||
@Override |
||||
public String getFindUrl() { |
||||
return FIND_URL; |
||||
} |
||||
|
||||
@Override |
||||
public boolean hasImg() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public boolean needSearch() { |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* 获取书城小说分类列表 |
||||
* |
||||
* @param html |
||||
* @return |
||||
*/ |
||||
public List<BookType> getBookTypes(String html) { |
||||
List<BookType> bookTypes = new ArrayList<>(); |
||||
Document doc = Jsoup.parse(html); |
||||
Elements divs = doc.getElementsByClass("nav_cont"); |
||||
if (divs.size() > 0) { |
||||
Elements uls = divs.get(0).getElementsByTag("ul"); |
||||
if (uls.size() > 0) { |
||||
for (Element li : uls.get(0).children()) { |
||||
Element a = li.child(0); |
||||
BookType bookType = new BookType(); |
||||
bookType.setTypeName(a.attr("title")); |
||||
bookType.setUrl(a.attr("href")); |
||||
if (bookType.getTypeName().contains("首页") || bookType.getTypeName().contains("热门小说")) |
||||
continue; |
||||
if (!StringHelper.isEmpty(bookType.getTypeName())) { |
||||
bookTypes.add(bookType); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
return bookTypes; |
||||
} |
||||
|
||||
/** |
||||
* 获取某一分类小说排行榜列表 |
||||
* |
||||
* @param html |
||||
* @return |
||||
*/ |
||||
public List<Book> getBookRankList(String html) { |
||||
List<Book> books = new ArrayList<>(); |
||||
Document doc = Jsoup.parse(html); |
||||
Elements divs = doc.getElementsByClass("r"); |
||||
if (divs.size() > 0) { |
||||
Elements uls = divs.get(0).getElementsByTag("ul"); |
||||
if (uls.size() > 0) { |
||||
for (Element li : uls.get(0).children()) { |
||||
Book book = new Book(); |
||||
Element scanS1 = li.getElementsByClass("s1").get(0); |
||||
Element scanS2 = li.getElementsByClass("s2").get(0); |
||||
Element scanS5 = li.getElementsByClass("s5").get(0); |
||||
book.setType(scanS1.html().replace("[", "").replace("]", "")); |
||||
Element a = scanS2.getElementsByTag("a").get(0); |
||||
book.setName(a.attr("title")); |
||||
book.setChapterUrl(a.attr("href")); |
||||
book.setAuthor(scanS5.html()); |
||||
book.setSource(LocalBookSource.biquge.toString()); |
||||
books.add(book); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return books; |
||||
} |
||||
|
||||
public List<Book> getFindBooks(String html, BookType bookType) { |
||||
List<Book> books = new ArrayList<>(); |
||||
Document doc = Jsoup.parse(html); |
||||
try { |
||||
int pageSize = Integer.parseInt(doc.getElementsByClass("last").first().text()); |
||||
bookType.setPageSize(pageSize); |
||||
} catch (Exception ignored) { |
||||
} |
||||
String type = doc.select("meta[name=keywords]").attr("content").replace(",全本小说网", ""); |
||||
Element div = doc.getElementById("tlist"); |
||||
Elements uls = div.getElementsByTag("ul"); |
||||
if (uls.size() > 0) { |
||||
for (Element li : uls.get(0).children()) { |
||||
Book book = new Book(); |
||||
Element aName = li.getElementsByClass("name").get(0); |
||||
Element divZz = li.getElementsByClass("zz").get(0); |
||||
Element divAuthor = li.getElementsByClass("author").get(0); |
||||
Element divSj = li.getElementsByClass("sj").get(0); |
||||
book.setType(type); |
||||
book.setName(aName.attr("title")); |
||||
book.setChapterUrl(aName.attr("href")); |
||||
book.setNewestChapterTitle(divZz.text()); |
||||
book.setAuthor(divAuthor.text()); |
||||
book.setUpdateDate(divSj.text()); |
||||
book.setSource(LocalBookSource.qb5.toString()); |
||||
books.add(book); |
||||
} |
||||
} |
||||
|
||||
return books; |
||||
|
||||
} |
||||
|
||||
public boolean getTypePage(BookType curType, int page) { |
||||
if (curType.getPageSize() <= 0) { |
||||
curType.setPageSize(10); |
||||
} |
||||
if (page > curType.getPageSize()) { |
||||
return true; |
||||
} |
||||
if (!curType.getTypeName().equals("完本小说")) { |
||||
curType.setUrl(curType.getUrl().substring(0, curType.getUrl().lastIndexOf("_") + 1) + page + "/"); |
||||
} else { |
||||
curType.setUrl(curType.getUrl().substring(0, curType.getUrl().lastIndexOf("/") + 1) + page); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,123 @@ |
||||
package xyz.fycz.myreader.webapi.crawler.find; |
||||
|
||||
import android.text.Html; |
||||
|
||||
import org.jsoup.Jsoup; |
||||
import org.jsoup.nodes.Document; |
||||
import org.jsoup.nodes.Element; |
||||
import org.jsoup.select.Elements; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import xyz.fycz.myreader.entity.SearchBookBean; |
||||
import xyz.fycz.myreader.entity.bookstore.BookType; |
||||
import xyz.fycz.myreader.enums.LocalBookSource; |
||||
import xyz.fycz.myreader.greendao.entity.Book; |
||||
import xyz.fycz.myreader.greendao.entity.Chapter; |
||||
import xyz.fycz.myreader.model.mulvalmap.ConcurrentMultiValueMap; |
||||
import xyz.fycz.myreader.webapi.crawler.base.FindCrawler; |
||||
import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; |
||||
|
||||
|
||||
public class XS7FindCrawler extends FindCrawler{ |
||||
public static final String NAME_SPACE = "https://www.xs7.la"; |
||||
public static final String CHARSET = "GBK"; |
||||
public static final String SEARCH_CHARSET = "GBK"; |
||||
public static final String FIND_NAME = "书城[小说旗]"; |
||||
|
||||
@Override |
||||
public String getCharset() { |
||||
return CHARSET; |
||||
} |
||||
|
||||
@Override |
||||
public String getFindName() { |
||||
return FIND_NAME; |
||||
} |
||||
|
||||
@Override |
||||
public String getFindUrl() { |
||||
return NAME_SPACE; |
||||
} |
||||
|
||||
@Override |
||||
public boolean hasImg() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public boolean needSearch() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public List<BookType> getBookTypes(String html) { |
||||
List<BookType> bookTypes = new ArrayList<>(); |
||||
Document doc = Jsoup.parse(html); |
||||
Element div = doc.getElementsByClass("subnav-hot").first(); |
||||
Elements as = div.getElementsByTag("a"); |
||||
for (Element a : as) { |
||||
BookType bookType = new BookType(); |
||||
bookType.setUrl(a.attr("href")); |
||||
bookType.setTypeName(a.text()); |
||||
bookTypes.add(bookType); |
||||
} |
||||
return bookTypes; |
||||
} |
||||
|
||||
/* |
||||
<div id="alistbox"> |
||||
<div class="pic"><a target="_blank" href="https://www.xs7.la/book/1_1201/" title="带着农场混异界最新章节列表"><img src="https://www.xs7.la/files/article/image/1/1201/1201s.jpg" |
||||
alt="带着农场混异界" title="带着农场混异界" width="115" height="160"></a></div> |
||||
<div class="info"> |
||||
<div class="title"> |
||||
<h2><a target="_blank" href="https://www.xs7.la/book/1_1201/">带着农场混异界</a></h2> |
||||
<span>作者:明宇</span> |
||||
</div> |
||||
<div class="sys">最新更新:<a href="https://www.xs7.la/book/1_1201/47219709.html" target="_blank" title="第四百四十七章 小山">第四百四十七章 |
||||
小山</a></div> |
||||
<div class="intro"> 他横任他横,我自种我田,若要来惹我,过不了明年。 |
||||
宅男赵海带着QQ农场穿越到了异界,附身到了一个落迫的小贵族身上,他的封地是一片种不出东西的黑土地,而最主要的是,...</div> |
||||
<div class="yuedu"> |
||||
<a target="_blank" href="https://www.xs7.la/book/1_1201/">全文阅读</a> |
||||
<a href="https://www.xs7.la/modules/article/addbookcase.php?bid=1201">加入书架</a> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
*/ |
||||
@Override |
||||
public List<Book> getFindBooks(String html, BookType bookType) { |
||||
List<Book> books = new ArrayList<>(); |
||||
Document doc = Jsoup.parse(html); |
||||
Element last = doc.getElementsByClass("last").first(); |
||||
bookType.setPageSize(Integer.parseInt(last.text())); |
||||
Element div = doc.getElementById("alist"); |
||||
Elements bDivs = div.select("div[id=alistbox]"); |
||||
for (Element bDiv : bDivs) { |
||||
Book book = new Book(); |
||||
Element title = bDiv.getElementsByClass("title").first(); |
||||
Element sys = bDiv.getElementsByClass("sys").first(); |
||||
Element intro = bDiv.getElementsByClass("intro").first(); |
||||
book.setName(title.getElementsByTag("a").first().text()); |
||||
book.setAuthor(title.getElementsByTag("span").first().text().replace("作者:", "")); |
||||
book.setNewestChapterTitle(sys.getElementsByTag("a").first().text()); |
||||
book.setImgUrl(bDiv.getElementsByTag("img").attr("src")); |
||||
book.setDesc(intro.text()); |
||||
book.setType(bookType.getTypeName()); |
||||
book.setChapterUrl(title.getElementsByTag("a").first().attr("href")); |
||||
book.setSource(LocalBookSource.xs7.toString()); |
||||
books.add(book); |
||||
} |
||||
return books; |
||||
} |
||||
|
||||
@Override |
||||
public boolean getTypePage(BookType curType, int page) { |
||||
if (page != 1 && page > curType.getPageSize()) { |
||||
return true; |
||||
} |
||||
curType.setUrl(curType.getUrl().substring(0, curType.getUrl().lastIndexOf("_") + 1) + page + ".html"); |
||||
return false; |
||||
} |
||||
} |
Loading…
Reference in new issue