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

casper-base

v0.1.1

Published

A CasperJs module some boilerprate to start writing a scraper

Downloads

5

Readme

casper-base | Utils for scraping the web with CasperJs

Build

CasperJs

A personal, simple module of CasperJs for scraping the web!

Explanation

Turned out that there are some configurations (and some utils) that I always needed (re)writing a scraper in CasperJs. So I'm trying to wrap every simple and almost full configurable piece of code to start new projects from here and not totally from scratch or with copy-paste.

Usage

Install

You can simply install via NPM, but the require will be a little bigger cause you will run it with CasperJs and not with NodeJs.

npm install casper-base

Or clone the repo if you want start from here:

git clone https://github.com/LasaleFamine/casper-base.git

Or simply download the main files:

  • /custom-utils (entire folder)
  • config.json
  • casper_base.js

And put them in the root directory of your project.

Configure

Right now you can change directly the config.json file of the NPM module to change the configuration of your casper.create() method. You can also clone this repo and change the configurations as you want.

For more information about CasperJs configuration: Casper Options

{
  "clientScripts":  [],
  "pageSettings": {
      "loadImages":  false,
      "loadPlugins": false
  },
  "logLevel": "warning",
  "verbose": true
}

Import

Simply require for your casper instance the casper_base module.

If was installed via NPM:

  var casper = require('./node_modules/casper-base/casper_base')

Or if the file is in your root directory:

  var casper = require('./casper_base')

Don't forget to leave the custom-utils folder within the main casper_base with the current hierachy.

Start scraping!

First install casperjs and phantomjs if you did't yet:

npm install --save casperjs phantomjs

Write your first scrapy!


var casper = require('./casper_base')

// Simulate error 404
casper.start('http://google.com/sad')
casper.run()

Fork it

Forks are always appreciate! :airplane: