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

openscraping-api-server

v0.1.1

Published

The OpenScraping API server allows calling the OpenScraping Node.js library through an HTTP API to extract information from HTML pages using a JSON config file with xPath rules.

Downloads

4

Readme

OpenScraping API Server

license:isc Build Status npm package version devDependencies:?

The OpenScraping API server allows calling the OpenScraping Node.js library through an HTTP API to extract information from HTML pages using a JSON config file with xPath rules.

The server provides two features:

  • A JSON HTTP API that allows sending in a JSON config and an HTML page and getting back the extracted data.
  • An HTML and JavaScript test console that can be accessed from the browser and which allows testing JSON configs against HTML pages.

The server does not contain a crawler, it just runs rules on a JSON config and HTML file sent in through an HTTP POST.

Please see the OpenScraping Node.js library for more detailed documentation on the JSON config.

Getting started

Install and run the API server:

npm install openscraping-api-server
node node_modules/openscraping-api-server/index.js --port 8080 --start api --start proxy --start rules_ux

Now go to http://localhost:8080/ to see the test console:

Available components

In the Getting Started section above we used --start command line arguments to start the three available components. You do not need to start all of them, especially in production. Here is what these components do:

Component | Dependency | Description --------- | ---------- | ------- api | - | This component runs the actual HTTP API that makes use of the OpenScraping Node.js library. See the Accessing the API Server programatically section below on how to use the API. proxy | api | The proxy is used by the rules_ux component to download single HTML pages when users click the Download HTML page in the UX. Warning: Do not expose this server externally on the Internet when the proxy component is turned on. It could be used maliciously because it can download any HTML page accessible from the machine this server is running on. rules_ux | api, proxy | This component provides the UX (see screenshot above) that allows for quick testing and development of new xPath rules against HTML pages.

Accessing the API Server programatically

Below is sample code that assumes you have jQuery available and loaded. It should be straighforward to access the API from any other language.

// Config containts the JSON config (as string!), and html contains the HTML of the pages we are scraping
var requestJson = JSON.stringify({ config: config, html: html })

$.post({
  url: "http://localhost:8080/api/evaluate",
  data: requestJson,
  success: function (data) {
    console.log(data)
  },
  error: function (err) {
    console.log(err)
  }
})