Add barebones Pixiv parser
parent
48c37abd82
commit
3c5923ba6d
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "neo-scraper",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"description": "Scrape a booru-like post object from the DOM.",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.js",
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export default class NeoScraper {
|
|||
new engines.Danbooru(),
|
||||
new engines.Gelbooru(),
|
||||
new engines.Moebooru(),
|
||||
new engines.Pixiv(),
|
||||
new engines.Reddit(),
|
||||
new engines.SankakuComplex(),
|
||||
new engines.Shimmie2(),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
import { ScrapeEngine, ScrapeResult, ScrapedPost, ScrapedTag } from "../ScrapeEngine";
|
||||
import { TagCategory } from "../BooruTypes";
|
||||
|
||||
export default class Pixiv implements ScrapeEngine {
|
||||
name = "pixiv";
|
||||
|
||||
canImport(url: Location): boolean {
|
||||
return (
|
||||
url.host == "pixiv.net" ||
|
||||
url.host == "www.pixiv.net"
|
||||
);
|
||||
}
|
||||
|
||||
scrapeDocument(document: Document): ScrapeResult {
|
||||
let result = new ScrapeResult(this.name);
|
||||
|
||||
const imgLinks = Array.from(document.querySelectorAll("div[role='presentation'] > a")).map(x => x as HTMLAnchorElement);
|
||||
|
||||
for (const imgLink of imgLinks) {
|
||||
let post = new ScrapedPost();
|
||||
post.source = document.location.href;
|
||||
post.imageUrl = imgLink.href;
|
||||
result.tryAddPost(post);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ export { default as Danbooru } from "./Danbooru";
|
|||
export { default as Fallback } from "./Fallback";
|
||||
export { default as Gelbooru } from "./Gelbooru";
|
||||
export { default as Moebooru } from "./Moebooru";
|
||||
export { default as Pixiv } from "./Pixiv";
|
||||
export { default as Reddit } from "./Reddit";
|
||||
export { default as SankakuComplex } from "./SankakuComplex";
|
||||
export { default as Shimmie2 } from "./Shimmie2";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom",
|
||||
"dom.iterable"
|
||||
],
|
||||
"outDir": "./dist/",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue