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

@waynechang65/baha-crawler

v2.6.0

Published

A web crawler module designed to scarp data from Bahamut forum.

Downloads

3

Readme

npm npm Npm package total downloads Build Status GitHub

baha-crawler

baha-crawler 是一個專門用來爬巴哈姆特各版資料的爬蟲模組。

baha-crawler is a web crawler module designed to scarp data from Bahamut Forum.

前言(Overview)

巴哈姆特是台灣最大的電玩討論區,也是許多台灣玩家不可不知的電玩資訊網站。 找了一下,似乎巴哈的爬蟲少之又少,更別說是用Javascript所寫的模組了。 本人為了在Node.js上爬巴哈姆特,乾脆就自己用javascript打造一個簡單的爬蟲模組,並且分享給大家使用。

Bahamut Forum is the most famous and biggest game forum in Taiwan and game plays are well-know forum. Just search a while, Bahamut Forum crawler modules are not easy to be found especially written by javascript.
In order to scrap data from Bahamut Forum by Node.js, I just create a simple Bahamut Forum crawler module by javascript and share it to everyone to use.

這個爬蟲模組能做什麼事? (What can it do ?)

  • 巴哈姆特任意版上資料。
    Scraping posts of any board on 巴哈姆特
  • 可以爬多頁資料。
    Support to scrape pages in one time
  • 爬資料時,可選擇是否忽略置頂文
    Support to skip fixed upper posts
  • 爬的資料以單一帖發文為單位,其中包含該帖的主題超連結。(其他資料如推文數、日期及作者等,因為個人目前用不到,所以尚未實作,有興趣歡迎fork and PR)
    Scraped posts contain titles and hyperlinks.(Other data like authers, dates, likes,... are not implimented yet and welcome to fork send PR)

如何在您的專案使用? (How to use it in your project ?)

  • 利用 npm 套件進行下載
    Use npm to install
npm install @waynechang65/baha-crawler
  • 在您的專案環境中,引用 baha-crawler模組。
    Include @waynechang65/baha-crawler package in your project
const baha_crawler = require('@waynechang65/baha-crawler');
  • 接下來,用async函式包含下面幾行程式就搞定了。
    Add programs below in an async function in your project
// *** Initialize ***  
await baha_crawler.initialize();

// *** GetResult  ***
    let baha = await baha_crawler.getResults({
        board: '23805',
        pages: 3,
        skipTPs: true
    }); // ToS Board(23805), 3 pages, skip fixed upper posts

// *** Close      ***
await baha_crawler.close();
  • 爬完的資料會透過函式 getResults() 回傳一個物件,裏面各陣列放著爬完的資料,結構如下:
    Scraped data will be returned with an object by getResults() function, it shows below.
{ titles[], urls[] }

如何跑範例程式? (How to run the example ?)

  • 從Github下載baha-crawler專案程式碼。
    Clone baha-crawler from GitHub
git clone https://github.com/WayneChang65/baha-crawler.git
  • 進入baha-crawler專案目錄
    Get into baha-crawler directory
cd baha-crawler
  • 下載跑範例程式所需要的環境組件
    Install dependencies in the cloned baha-crawler folder
npm install
  • 透過 npm 直接使用以下指令。(實際範例程式在 ./examples/demo.js)
    Run it with npm. (the demo example is in ./examples/demo.js)
npm run start

image

基本函式 (Base Methods)

  • initialize(): 初始化物件, initialize baha-crawler object
  • getResults(options): 開始爬資料,scrape data

options.board: 欲爬的巴哈版名編號, board name of baha
options.pages: 要爬幾頁, pages
options.skipTPs: 是否忽略置頂文, skip fixed upper posts or not

  • close(): 關閉物件, close baha-crawler object

參考網站 (Reference)

貢獻一己之力 (Contribution)

baha-crawler 雖然是一個小模組,但本人還是希望這個專案能夠持續進步!若有發現臭蟲(bug)或問題,請幫忙在Issue留言告知詳細情形。
歡迎共同開發。歡迎Pull Request,謝謝。:)

Even though baha-crawler is a small project, I hope it can be improving. If there is any issue, please comment and welcome to fork and send Pull Request. Thanks. :)