Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2 var page = require('webpage').create();
- 3 var fs = require('fs');
- 4
- 5 console.log(phantom.injectJs('./jquery.min.js'));
- 6
- 7 var URL = 'http://data.bls.gov/location_quotient/ControllerServlet';
- 8 var MSA_options = new Array();
- 9
- 10 page.onLoadFinished = function(status){
- 11 // If the page did not load successfully:
- 12 if (status !== 'success')
- 13 phantom.exit();
- 14
- 15 // If the page did load successfully:
- 16
- 17 var content = page.content;
- 18 var options = $('select[name|="analysis_area1"]',content)[0].options;
- 19 console.log(options.length);
- 20
- 21 $(options).each(function(index){
- 22 var x = options[index];
- 23 if(x.text.indexOf('MSA') >= 0){
- 24 MSA_options.push([$.trim(x.text),index]);
- 25 }
- 26 });
- 27
- 28 beginMiningOperation();
- 29
- 30
- 31 }
- 32
- 33 page.open(URL);
- 34
- 35 function beginMiningOperation(){
- 36 actionPage = require('webpage').create();
- 37 var finishedLoading = function(status){
- 38 if(status!=='success')
- 39 console.log('PageFailedToLoad!');
- 40
- 41 actionPage.render('datapage.png');
- 42
- 43 phantom.exit();
- 44 }
- 45
- 46 var subarr = MSA_options.slice(0,3);
- 47 //for(var i;i<MSA_options.length;i += 3){
- 48 actionPage.open(URL,function(){
- 49 actionPage.onLoadFinished = finishedLoading;
- 50 console.log(subarr);
- 51 actionPage.evaluate(function(subarr){
- 52 $('select[name|="analysis_area1"]')[0].selectedIndex = subarr[0][1];
- 53 $('select[name|="analysis_area2"]')[0].selectedIndex = subarr[1][1];
- 54 $('select[name|="analysis_area3"]')[0].selectedIndex = subarr[2][1];
- 55 $('input[name|="Sector"]')[0].checked = true;
- 56 $('#submit')[0].click();
- 57 },subarr);
- 58
- 59 });
- 60 //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement