Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tom-weatherhead/http-get-regex-capture
Obtain text via an HTTP GET request, and then capture pieces of the text with regular expressions.
https://github.com/tom-weatherhead/http-get-regex-capture
Last synced: about 8 hours ago
JSON representation
Obtain text via an HTTP GET request, and then capture pieces of the text with regular expressions.
- Host: GitHub
- URL: https://github.com/tom-weatherhead/http-get-regex-capture
- Owner: tom-weatherhead
- License: mit
- Created: 2017-09-27T00:42:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-29T18:40:59.000Z (about 6 years ago)
- Last Synced: 2024-10-14T13:55:26.015Z (about 1 month ago)
- Language: JavaScript
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http-get-regex-capture
[![build status](https://secure.travis-ci.org/tom-weatherhead/http-get-regex-capture.svg)](http://travis-ci.org/tom-weatherhead/http-get-regex-capture) [![downloads](https://img.shields.io/npm/dt/http-get-regex-capture.svg)](https://www.npmjs.com/package/http-get-regex-capture)
Obtain text via an HTTP GET request, and then capture pieces of the text with regular expressions.
The demo app determines the latest stable versions of Node.js and Ruby by scraping their respective Websites.
Git installation and execution instructions:
Install Git.
Install Node.js (e.g. via [nvm](https://github.com/creationix/nvm) or [Nodist](https://github.com/marcelklehr/nodist)).
In a terminal:
$ npm i -g grunt
$ git clone https://github.com/tom-weatherhead/http-get-regex-capture.git
$ cd http-get-regex-capture
$ npm i
$ grunt
$ npm start node
$ npm start rubyNote: The command "grunt" runs lint, unit, and security tests.
npm installation and execution instructions:
$ npm i -g http-get-regex-capture
$ thaw-latest-version-of node
$ thaw-latest-version-of rubyOptions:
- returnHttpResponseBody: Boolean. If true, the body of the HTTP response will be returned as result.httpResponseBody .
- returnHttpResponseStatus: Boolean. If true, the status code and status message of the HTTP response will be returned as result.httpResponseStatusCode and result.httpResponseStatusMessage respectively.
- returnMatchObject: Boolean.
Example 1:
const matchRegexesInWebPage = require('http-get-regex-capture');
const url = 'https://nodejs.org/en/';
const regexes = [
/Download v{0,1}(\S+)\s+Current/
];
const options = {
returnHttpResponseStatus: true
};matchRegexesInWebPage(url, regexes, options) // Returns a Promise from the npm package 'q'.
.then(result => {
console.log('HTTP Reponse status:', result.httpResponseStatusCode, result.httpResponseStatusMessage);
console.log('The latest available stable version of Node.js is', result.regexMatchResults[0].match);
})
.fail(error => {
console.error('Failed to determine the latest available stable version of Node.js. Error:', error);
})
.done();