-
-
Save srsbiz/1cd71dbe79369dd1682ddb2b2275a8e2 to your computer and use it in GitHub Desktop.
/** | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* * Redistributions of source code must retain the above copyright | |
* notice, this list of conditions and the following disclaimer. | |
* * Redistributions in binary form must reproduce the above copyright | |
* notice, this list of conditions and the following disclaimer in the | |
* documentation and/or other materials provided with the distribution. | |
* * Neither the name of the <organization> nor the | |
* names of its contributors may be used to endorse or promote products | |
* derived from this software without specific prior written permission. | |
* | |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | |
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
*/ | |
"use strict"; | |
/** | |
* https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js | |
*/ | |
function waitFor(testFunction, readyFunction, timeOutMillis) { | |
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3000, | |
start = new Date().getTime(), | |
condition = false, | |
interval = setInterval(function() { | |
if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) { | |
condition = (typeof(testFunction) === "string" ? eval(testFunction) : testFunction()); | |
} else { | |
if(!condition) { | |
phantom.exit(1); | |
} else { | |
typeof(readyFunction) === "string" ? eval(readyFunction) : readyFunction(); | |
clearInterval(interval); | |
} | |
} | |
}, 250); | |
}; | |
var system = require('system'), | |
args = system.args, | |
nip, | |
nieJest = "Podmiot o podanym identyfikatorze podatkowym NIP nie jest zarejestrowany jako podatnik VAT", | |
page = require('webpage').create(); | |
if (1 === args.length) { | |
console.log('NIP is required'); | |
phantom.exit(1); | |
} else { | |
nip = args[1]; | |
} | |
page.open('https://ppuslugi.mf.gov.pl/', function(status) { | |
if (status !== "success") { | |
console.log("Unable to access network"); | |
phantom.exit(); | |
} else { | |
waitFor(function(){ | |
return page.evaluate(function() { return $('#SidebarActions_WebUMn li').length > 0; }); | |
}, function(){ | |
page.evaluate(function() { | |
FWDC.executeAction(1005, null, 'FLOW'); | |
}); | |
waitFor(function(){ | |
return page.evaluate(function() { return $('#b-7').length > 0; }); | |
}, function(){ | |
page.evaluate(function(nip) { | |
$('#b-7').val(nip); | |
$('#b-8').trigger('click'); | |
}, nip); | |
waitFor(function(){ | |
return page.evaluate(function() { return $('#container_b-3').is(':visible'); }); | |
}, function() { | |
var msg = page.evaluate(function() { return $.trim($('#container_b-3').text()); }), | |
date = page.evaluate(function() { return $.trim($('#caption2_b-b').text().split(':')[1]).split('-').reverse().join('-'); }), | |
response = { | |
"nip": nip, | |
"msg": msg, | |
"date": date, | |
"status": msg == nieJest ? false : true | |
}; | |
system.stdout.write(JSON.stringify(response)); | |
phantom.exit(); | |
}); | |
}); | |
}); | |
} | |
}); |
1 0x1befef7 bin/phantomjs() [0x1befef7] 2 0x19fa215 bin/phantomjs() [0x19fa215] 3 0x1b11757 bin/phantomjs() [0x1b11757] 4 0x7df3c2 bin/phantomjs() [0x7df3c2] 5 0x7df6d7 bin/phantomjs() [0x7df6d7] 6 0x7d951d bin/phantomjs() [0x7d951d] 7 0x7bcbdf bin/phantomjs() [0x7bcbdf] 8 0x48e471 bin/phantomjs() [0x48e471] 9 0x43c7e0 bin/phantomjs() [0x43c7e0] 10 0x48625f bin/phantomjs() [0x48625f] 11 0x22cc0bc bin/phantomjs() [0x22cc0bc] 12 0x919f8b bin/phantomjs() [0x919f8b] 13 0x7deec4 bin/phantomjs() [0x7deec4] 14 0x7df68b bin/phantomjs() [0x7df68b] 15 0x7df6d7 bin/phantomjs() [0x7df6d7] 16 0x7d951d bin/phantomjs() [0x7d951d] 17 0x7bcbdf bin/phantomjs() [0x7bcbdf] 18 0x48e471 bin/phantomjs() [0x48e471] 19 0x44d9fd bin/phantomjs() [0x44d9fd] 20 0x432c66 bin/phantomjs() [0x432c66] 21 0x42d19e bin/phantomjs() [0x42d19e] 22 0x7fb4ce1fd830 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7fb4ce1fd830] 23 0x42ee89 bin/phantomjs() [0x42ee89] PhantomJS has crashed. Please read the bug reporting guide at <http://phantomjs.org/bug-reporting.html> and file a bug report.
Ja otrzymuję tylko taki wynik, co mogę robić źle?
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;