hamro-patro-scraper
v1.4.5
Published
A package to scrape Nepali date, time, daily horoscope, gold and silver rates and exchange rates from Hamro Patro.
Maintainers
Readme
hamro-patro-scraper
hamro-patro-scraper is an npm package for scraping Nepali date, time, daily horoscope, gold prices, and exchange rates from Hamro Patro. It provides a simple API for retrieving this information programmatically or via a command-line interface.
Installation
You can install hamro-patro-scraper globally to use the CLI or as a dependency in your Node.js project.
Install Globally
To install hamro-patro-scraper globally, use:
npm install -g hamro-patro-scraperInstall as a Dependency
To add hamro-patro-scraper to your project, run:
npm install hamro-patro-scraperUsage
Command-Line Interface (CLI)
Once installed globally, you can use the CLI to fetch Nepali date/time, daily horoscope, gold prices, and exchange rates.
Fetch Nepali Date and Time:
HamroPatro datetimeFetch Daily, Weekly, Monthly, Yearly Rashifal:
HamroPatro rashifal (daily | weekly | monthly | yearly)Fetch Gold Prices:
HamroPatro goldFetch Exchange Rates:
HamroPatro forex
Using in Node.js Code
You can also use hamro-patro-scraper in your Node.js applications. Here’s how:
Require the Package:
const { hamroPatro, getRashifal, getGoldPrices, getExchangeRates, } = require("hamro-patro-scraper");Fetch Nepali Date and Time:
(async () => { try { const dateTime = await hamroPatro(); console.log("Nepali Date and Time:", dateTime); } catch (error) { console.error("Error fetching Nepali date and time:", error.message); } })();Fetch Daily Horoscope:
const types = ["daily", "weekly", "monthly", "yearly"]; const fetchHoroscope = async (type = "daily") => { try { const horoscope = await getRashifal(type); console.log( `${type.charAt(0).toUpperCase() + type.slice(1)} Horoscope:` ); console.log(JSON.stringify(horoscope, null, 2)); console.log("-----------------------"); } catch (error) { console.error(`Error fetching ${type} horoscope:`, error.message); } }; // Example: fetch daily horoscope (default) fetchHoroscope(); // Or fetch all types: (async () => { for (const type of types) { await fetchHoroscope(type); } })();Fetch Gold Prices:
(async () => {
try {
const data = await getGoldPrices();
console.log(JSON.stringify(data, null, 2));
} catch (error) {
console.error("Error fetching gold prices:", error.message);
}
})();- Fetch Exchange Rates:
(async () => {
try {
const data = await getExchangeRates();
console.log(JSON.stringify(data, null, 2));
} catch (error) {
console.error("Error fetching exchange rates:", error.message);
}
})();API
hamroPatro()
Returns an object with the following properties:
nepaliDate: The current Nepali date.currentTime: The current time in Nepali time.englishDate: The current date in the Gregorian calendar.
getRashifal()
Returns an array of horoscope objects with the following properties for each rashi (zodiac sign):
rashi: The index of the rashi (1-12).name: The Nepali name of the rashi.text: The horoscope description for the rashi.
getGoldPrices()
Logs the gold and silver prices directly to the console.
getExchangeRates()
Logs the exchange rates directly to the console.
License
This package is licensed under the Apache License 2.0.
Contributing
If you'd like to contribute to hamro-patro-scraper, please fork the repository and submit a pull request. Contributions, bug reports, and feature requests are welcome!
Contact
For any questions or issues, please open an issue on the GitHub repository.
hamro-patro-scraper is maintained by Milan Bhandari.
