npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

novels-raw-scraper

v1.4.5

Published

A library to handle scraping of chapter and table of contents for chinese novels.

Downloads

32

Readme

Novels Raw Scraper

A little library to handle scraping of chapter and table of contents for chinese novels.

npm bundle size npm node-current npm

Features.

  • Supports PTWXZ and 69Shu.
  • Get latest chapter info.
  • Automatically change chinese encoding to UTF-8.
  • Built on typescript.
  • Great DX support due to typescript.
  • Does not have fancy features and plain simple api.

Installation

Yarn

yarn add novels-raw-scraper

NPM

npm i novels-raw-scraper

Usage

Chapter Scraper

import { snChapterScraper } from "novels-raw-scraper";

// or

import { ptwxzChapterScraper } from "novels-raw-scraper";

// You need to input the chapter url, rest will be handled by the library.

await snChapterScraper("https://www.69shu.com/txt/35345/24661030");

await ptwxzChapterScraper("https://www.ptwxz.com/html/7/7811/9426848.html");

Output is an String[].
/*
[
  '第4章 ,只因为在人群中多看了一眼',
  '家里事物料理完毕,颜老太太就带着大孙女、三孙子,还有老仆二人,踏上了去往大儿上任的临宜县的路。',
  '颜老太太在族里的辈分比较高,加之这些年,颜家没少帮衬族里,是以,他们走的时候,族长和族中辈分比较高的老者都来了。',
  '“老嫂子,今年少雨,各个地方的收成都不太好,就我们颜家村,用了您老给的种子,收成比往年还要多上一成,我在这呀,替大家感谢你嘞。”',
  ...]
*/

Table of Contents Scraper

import { snTocScraper } from "novels-raw-scraper";

// or

import { ptwxzTocScraper } from "novels-raw-scraper";


// You need to input the chapter url, rest will be handled by the library.
await snTocScraper("https://www.69shu.com/31477/");

await ptwxzChapterScraper("https://www.ptwxz.com/html/7/7811/");

Output's `TocOutput` type of array which can easily be mapped later on.
/*
[
  {
    number: 1,
    title: '牢狱之灾',
    url: 'https://www.69shu.com/txt/31477/22493555'
  },
  {
    number: 2,
    title: '妖物作祟',
    url: 'https://www.69shu.com/txt/31477/22493560'
  },
  {
    number: 3,
    title: '仙侠世界一样能推理',
    url: 'https://www.69shu.com/txt/31477/22493564'
  },
  {
    number: 4,
    title: '是时候表演真正的技术了',
    url: 'https://www.69shu.com/txt/31477/22493570'
  },
  ... 820 more items
]
*/

Last chapter info scraper

import { lastChapterInfo } from "novels-raw-scraper";
import puppeteer from "puppeteer";

const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();

await lastChapterInfo({
  linkSelector: "link css selector",
  numberSelector: "number css selector",
  sourceUrl: "url of the page where we need to check",
  titleSelector: "title css selector",
  page: page, // Cheerio's page instance.
});

// OUTPUT

/*
{
  link: "https://chapterslink.com/123,
  number: 123,
  title: "Some great title"
}
*/

API

We currently support 2 sites and 2 functions each site, one for chapter text and other for toc.

ptwxzChapterScraper();
ptwxzTocScraper();

snChapterScraper();
snTocScraper();

The last chapter info function can virtually run on all sort of sites.

Visualization of this Repo.

Visualization of this repo