diff --git a/example_config.js b/example_config.js deleted file mode 100644 index 68784ca..0000000 --- a/example_config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports={ - fromEmail:'something@gmail.com', - fromPass:'*******', - toEmail:'something@gmail.com' -} diff --git a/package.json b/package.json deleted file mode 100644 index 5cde2e0..0000000 --- a/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "CarScrape", - "version": "0.0.0", - "description": "Scrape scapyard site", - "main": "scrape.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "https://github.com/apetherick/CarScrape.git" - }, - "author": "Alex Petherick", - "license": "ISC", - "bugs": { - "url": "https://github.com/apetherick/CarScrape/issues" - }, - "dependencies": { - "cheerio": "^0.19.0", - "nodemailer": "^1.8.0", - "sendmail": "^0.2.1" - } -} diff --git a/scrape.js b/scrape.js deleted file mode 100644 index 1d6eeb8..0000000 --- a/scrape.js +++ /dev/null @@ -1,60 +0,0 @@ -var cheerio = require( "cheerio" ); -var request = require( "request" ); -var fs = require("fs"); -var sendmail = require('sendmail')(); -var nodemailer = require('nodemailer'); -var config = require('./config.js'); -var fullUrl = "http://www.u-pull-it.co.uk" - -var thefile = __dirname+'/file'; -var URLS = [ - "https://www.u-pull-it.co.uk/search/catalogue/Breaker-Parts/yard/York/cartype/Vehicles-Under-7.5-Tonnes/make/Volkswagen/model/Golf", - "https://www.u-pull-it.co.uk/search/catalogue/Breaker-Parts/yard/York/cartype/Vehicles-Under-7.5-Tonnes/make/Volkswagen/model/Bora", -] - -URLS.forEach(function(URL){Scrape(URL)}); - -function Scrape(URL){ - request( {"url":URL, "rejectUnauthorized": false}, function( err, code, data ) { - if ( err ) { - console.log("Error making request" + err); - return; - }else{ - console.log(URL); - } - $ = cheerio.load( data ); - - $( "dl.lotInfo + a.viewButton" ).filter( function() { - var thisurl = this; - fs.readFile(thefile,"utf8", function (err, data) { - if (err) throw err; - if(data.indexOf(thisurl.attribs.href)===-1){ - //email - console.log(config.fromEmail); - var transporter = nodemailer.createTransport({ - service: 'gmail', - auth: { - user: config.fromEmail, - pass: config.fromPass - } - }); - setTimeout(function(){ - transporter.sendMail({ - from: config.fromEmail, - to: config.toEmail, - subject: 'New Stock!', - text: thisurl.attribs.href - }, function(err, info){console.log(err); console.log(info);}); - fs.appendFile(thefile, thisurl.attribs.href+'\n', 'utf8'); - console.log(thisurl.attribs.href); - }, Math.floor(Math.random() * 100000)); - } - }); - } ); - $( "li.pager-next a").filter(function(){ - var thisNext = this; - Scrape(fullUrl + thisNext.attribs.href); - }); - } ); -} -