An (unofficial) API for Hidabroot
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.
npm install hidabroot
Or with yarn:
yarn add hidabroot
import { todayNews } from "hidabroot";
todayNews().then((news) => {
console.log(news);
});
//=> JSON object containing news titles along with their IDs
(also compitable with commonjs)
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
}
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).
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
Type: string
The query to search for in the website.
Type: searchOptions
The options for the search. Recommended to get better results.
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.
Type: number
The "Ask The Rabbi" question ID. Can be found in https://www.hidabroot.org/question/X
where X is the question ID.
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)
Type: string
The input URL of the Hidabroot page to extract the ID from.
Type: idExtracterOptions
The options for the extract process.
import { idExtracter } from "hidabroot";
const questionID = idExtracter("https://www.hidabroot.org/question/75137", {
pageType: "askTheRabbi",
});
console.log(questionID);
//=> 75137
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.