Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: Arkansas Scraper #26

Merged
merged 5 commits into from
Oct 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions scrapers/ar/config.yml
@@ -0,0 +1,2 @@
name: Arkansas
index_url: "http://www.arkansas.gov/dfa/procurement/bids/index.php"
59 changes: 59 additions & 0 deletions scrapers/ar/rfps.js
@@ -0,0 +1,59 @@
var cheerio = require("cheerio"),
request = require("request"),
_ = require("underscore"),
async = require("async");

var START_URL = "http://www.arkansas.gov/dfa/procurement/bids/index.php",
BASE_URL = "http://www.arkansas.gov/dfa/procurement/bids/";

var FIELDS = {
"Bid Number:": "id",
"Agency:": "department_name",
"Description:": "title",
"Buyer's Email:": "contact_email"
}

module.exports = function(opts, done) {
getSolicitationUrls(START_URL, function(links) {
//copied from illinois scraper example
links = opts.limit > 0 ? _.first(links, opts.limit): links;
async.mapLimit(links, 5, getSolicitationDetails, function(error, results) {
if(error) {throw new Error(error); }
console.log("Done scraping!");
done(results);
});
});
}

// pull links for each solicitation (needed for attachments)
function getSolicitationUrls(startUrl, cb) {

request.get(startUrl, function(error, response, html) {
if(!error) {
var urls = [];
var $ = cheerio.load(html);
$('table tr td font.rowitem1 a').each(function(){
var url = BASE_URL + $(this).attr('href');
urls.push(url);
});
cb(urls);

}
});
}

function getSolicitationDetails(url, cb){
var json = {"id": "","html_url": url, "type": "RFP"};
request.get(url, function(error, response, html) {
var $ = cheerio.load(html);
$('#mainContent table tr td[align="center"] div[align="center"] table td').each(function() {
event = $(this).text().trim();
if (event in FIELDS) {
json[FIELDS[event]] = $(this).next().text().trim();
}
});
cb(null, json);
});
}