Giter Site home page Giter Site logo

hidabroot's Introduction

Hidabroot API (unofficial)

version typescript issues pull requests Build Status

An (unofficial) API for Hidabroot

Important notice

This API is unofficial, meaning I am not responisble for any damage caused by using this API. This API may be blocked at any time by Hidabroot's team. This API is never stable as Hidabroot can change at any time their website structure that will break this API.

Install

npm install hidabroot

Or with yarn:

yarn add hidabroot

Usage

import { todayNews } from "hidabroot";

todayNews().then((news) => {
  console.log(news);
});
//=> JSON object containing news titles along with their IDs

(also compitable with commonjs)

API

todayNews()

Example

const { todayNews } = require("hidabroot");
todayNews().then((result) => {
  console.log(result);
});

Will return something like this:

{
  "big article block title is here": 123456, //the number is the article ID. can be used with getArticle()
  "first small article block title is here": 123456,
  "second small article block title is here": 123456,
  "third small article block title is here": 123456,
  "fourth small article block title is here": 123456
}

getArticle(id)

id

Type: number

The ID of the article. The ID can be found in the URL: https://www.hidabroot.org/article/X (X is the ID).

Example

const { getArticle } = require("hidabroot");
getArticle(1185334).then((result) => console.log(result));
//gets the content of the article: https://www.hidabroot.org/article/1185334 and then log the content to the console

search(query, options?)

query

Type: string

The query to search for in the website.

options

Type: searchOptions

The options for the search. Recommended to get better results.

Example

import { search } from "hidabroot";

const response = await search("האם היו עולמות קודמים?", {
  searchOptions: { searchType: "faq" }, // "faq" means "Ask The Rabbi" questions
});
console.log(response);

Which return to the console something like this:

{
  "url for result": "result title"
}

Currently (v0.8.0), the search is capable to return ~10-15 results. This may be changed in the future.

askTheRabbi(questionID)

questionID

Type: number

The "Ask The Rabbi" question ID. Can be found in https://www.hidabroot.org/question/X where X is the question ID.

Example

import { askTheRabbi, idExtracter } from "hidabroot";

const questionID = idExtracter("https://www.hidabroot.org/question/75137", {
  pageType: "askTheRabbi",
});
const response = await askTheRabbi(questionID);
console.log(response);

Which return to the console something like this:

{
  "title": "the question title",
  "question": "the question",
  "answer": "the rabbi answer"
}

(or null if the page wasn't found or if an error occurred)

idExtracter(input, options)

input

Type: string

The input URL of the Hidabroot page to extract the ID from.

options

Type: idExtracterOptions

The options for the extract process.

Example

import { idExtracter } from "hidabroot";

const questionID = idExtracter("https://www.hidabroot.org/question/75137", {
  pageType: "askTheRabbi",
});
console.log(questionID);
//=> 75137

Contributing

All contributions are welcome! Feel free to open an issue (just search the issue tracker before opening an issue to make sure your issue hasn't already been reported or answered) or a pull request.

hidabroot's People

Contributors

itsrn avatar

Stargazers

 avatar

Watchers

 avatar  avatar

hidabroot's Issues

The package doesn't work on replit

Description

When using the package in replit, I get the following error:

Error: Error: Could not find Chrome (ver. 115.0.5790.98). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npm install`) or
 2. your cache path is incorrectly configured (which is: /home/runner/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.

Steps to reproduce

  1. Install the package in replit
  2. Use todayNews() function
  3. Get the error

Expected behavior

The function should work and return the array as expected

Hidabroot API Version

0.5.5-beta

Operating System

  • macOS
  • Windows
  • #7

Package doesn't work

Description

The package does not work because the /build/index.js does not exist.

Steps to reproduce

  1. Install the package
  2. Import the package
  3. Get the error:
Error: Cannot find module '..../node_modules/hidabroot/build/index.js'. Please verify that the package.json has a valid "main" entry

Expected behavior

Able to use the package

Hidabroot API Version

0.5.3-beta

Operating System

  • macOS
  • Windows
  • Linux

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.