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

bill-scraper

v1.2.0

Published

A JavaScript API to scrape and analyze bills in Congress.

Downloads

9

Readme

BillScraper.js 📝📝📝

Build Status codecov npm version Inline docs

A NPM module to scrape and analyze bills in Congress. Works for bills from the 113th, 114th, and 115th congress. THIS PROJECT IS STILL UNDER DEVELOPMENT. DO NOT DOWNLOAD YET.

Table of Contents

  • docs: Holds markdown files that explain the project in more detail.
  • examples: Holds example code.
  • example_outputs: Holds example outputs.
  • lib: Holds all Javascript files
  • misc: Hold all graphics for the README.md
  • test: Holds all unit tests.

Why?

The government hosts bulk data for all congressional bills at gpo.gov/fdsys/bulkdata. However, this repository is horrible to use for developers, as bills are uploaded to unpredictable URLS as XML files. Each bill file is too structured, as XML style elements like paragraphs, bold text, and quotes are preserved, making it hard to parse the actual text of a bill.

What does this project do

  • Returns full Congressional bill text and metadata from Congress.gov as JSON. This library can scrape both the actual bill text (bills) and meta information such as cosponsors, amendments, and committees (bill statuses). For example, the following code will convert the XML (on the top) into the JSON (on the bottom)
var billScraper = require("bill-scraper");

billScraper.getBill("BILLS-113hr1033rs", function(res){
  billScraper.printBill(res, function(parsedResult){
    console.log(JSON.stringify(parsedResult));
  });
}, {session: 2});

XML | JSON
:-----------------------:|:-----------------------: XML | JSON

For more detailed examples, visit examples/get_bills.js.

  • Parses bills for key points and ideas: This project generates "tags" for bills, allowing them to more easily searched. For instance, searching for all bills tagged with "battlefield".
var billScraper = require("bill-scraper");

billScraper.getBill("BILLS-113hr1033rs", function(res){
 billScraper.printBill(res, function(parsedResult){
   billScraper.tagBill(parsedResult, function(tags){
      console.log(tags);
   });
 });
}, {session: 2});

//Will return ['battlefield', 'sites','war','section','land','subsection','period','funds','appropriation','protection','revolutionary','public','sub','term','nations','civil','preservation','service','sellers','prohibition','purposes','person','entity','matter','influence','law','ratification','policy'];

For more detailed examples, visit examples/tag_bills.js.

  • Generates a searchable Mongo database of bills: For example, the following code will locally cache a database (see photo below) of parsed, searchable bills.
var billScraper = require("bill-scraper");
var mongoose = require("mongoose");

mongoose.connect("mongodb://localhost/bills");
billScraper.generateDB("hr", 115, 1);

Database

For documentation on the Bill struct stored in the database, visit BILL_TEMPLATE.md in docs, for more detailed examples, visit examples/database.js, and for information on searching bills, see the examples in examples/search_bills.js.

Documentation

  • To get started, visit GET_STARTED.md in docs.
  • For examples of how to use the library, visit examples.
  • Documentation for all the methods is available here.

Community

This repository encourages all users to contribute. Please read the Code of Conduct and Contributing.md. For things to contribute, check out the issues or TODO.md.

Datasets used

Relevant libraries used

View the package.json for the full list of dependencies.

Contributors

View the full list of contributors here.

License

This repository is licensed as CC0. See the LICENSE for more information.