Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // how to run it:
- // $ npm install cheerio
- // $ npm install request
- // $ npm install colors
- // $ node how-many-tickets-left.js
- var cheerio = require('cheerio');
- var request = require('request');
- var colors = require('colors');
- var URL = 'https://www.eventbrite.com/tickets-external?eid=10494321799&ref=etckt';
- var PATH = '#remaining_quant_23333901_None';
- request(URL, function (error, response, body) {
- if (error || response.statusCode !== 200) {
- throw new Error("Your intenet is jacked up. Try again when its sane again.");
- }
- var $ = cheerio.load(body);
- run($);
- });
- function run($) {
- var text = $(PATH).text();
- var match = /\d+/.exec(text);
- if (match === null) {
- throw new Error("The webpage is not displaying correctly. Check again.");
- }
- var tickets = match[0];
- if (tickets === 0) {
- console.log("Fuck. ".red + "They're out of tickets.");
- return;
- }
- if (tickets > 0) {
- console.log('Hell ya. '.rainbow + "They still have " + tickets + " tickets left.");
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement