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

wintr

v1.2.0

Published

Wintr (wintr.com) unofficial API wrapper

Downloads

11

Readme

Wintr Api Abstraction

Unofficial Wintr scrapper service abstraction

Build status Coverage Status Code Climate maintainability npm version Dependencies ISC license

Installation

npm i wintr

Usage

Wintr object should be instantiated with default options, including at least an Api key. See below for options description.

const w = new Wintr(options)

Two public methods are then available to interact with the Api :

  • Fetch Api : w.fetch(options) : Promise<>
  • Get account data : w.getAccountData(options): Promise<>

Options

Options are detailed here, and are available as constants in the module for easy rules writing

'Real-life' example

Extracting title and price from an Amazon product page :

const { Wintr, constants } = require('wintr')

const scraper = new Wintr({
 [constants.PARAMETERS.API_KEY]: 'myApiKey',
 [constants.PARAMETERS.JS_RENDERING]: true
})

scraper.fetch({
  [constants.PARAMETERS.URL]: 'https://amazon.com/dp/productId',
  [constants.PARAMETERS.OUTPUT_SCHEMA]: {
    product: {
      [constants.PARAMETERS.GROUP_CSS_SELECTOR]: 'body',
      [constants.PARAMETERS.GROUP_SCHEMA_DESCRIPTOR]: {
        productTitle: {
          [constants.OUTPUT_SCHEMA_DESCRIPTORS.CSS_SELECTOR]: '#productTitle',
          [constants.OUTPUT_SCHEMA_DESCRIPTORS.CSS_ATTRIBUTE]: '*text*',
          [constants.OUTPUT_SCHEMA_DESCRIPTORS.WINTR_MODIFIER]: [
            constants.OUTPUT_SCHEMA_MODIFIERS.TRIM_RESULT
          ]
        },
        price: {
          [constants.OUTPUT_SCHEMA_DESCRIPTORS.CSS_SELECTOR]: '#priceblock_ourprice',
          [constants.OUTPUT_SCHEMA_DESCRIPTORS.CSS_ATTRIBUTE]: '*text*',
          [constants.OUTPUT_SCHEMA_DESCRIPTORS.WINTR_MODIFIER]: [
            constants.OUTPUT_SCHEMA_MODIFIERS.TRIM_RESULT
          ],
          [constants.OUTPUT_SCHEMA_DESCRIPTORS.WINTR_REPLACER]: [
            {
              [constants.OUTPUT_SCHEMA_REPLACER.SEARCH]: '$',
              [constants.OUTPUT_SCHEMA_REPLACER.REPLACE_BY]: ''
            }
          ]
        }
      }
    }
  }
})
.then(({ content }) => { 
  console.log(content)
  // Logs something like that :
  // {
  //    productTitle: "Super cool product that everyone will like",
  //    price: "999.99"
  // }
})
.catch(console.error)

Development

Tests and examples are not included in the Npm release to keep it lightweight. Use the repository for development

Tests

Tests are handled by ava, and coverage by nyc.

Commands includes :

  • npm run test : Run tests
  • npm run coverage : Run tests through nyc, and output lcov file

Example

An example application is included. Run it with :

npm run dev

and open your browser at localhost:8080

Contributing

Issue reports, pull requests, suggestions and comments are very welcome, don't hesitate !

Please keep in mind that this repo use commitizen -style commit messages and follow js standard's style

License

ISC

Copyright (c) 2020, 121593