obdfcascrape/tests/scrape.dk.js
Martin Donnelly be5d3eae07 init
2019-05-05 20:13:56 +01:00

379 lines
25 KiB
JavaScript

const tape = require('tape');
const _test = require('tape-promise').default; // <---- notice 'default'
const test = _test(tape); // decorate tape
const Denmark = require('../ncas/dk');
const body = `<body id="body">
<div class="root-box">
<div class="root imagepng">
<form name="mainform" method="post" action="/Tal-og-fakta/Virksomheder-under-tilsyn/VUT-vis-virksomhed.aspx?id=A18A7F4B-F126-E511-80EA-00505680286D" id="mainform">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="">
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJODI5MTM0MDg4D2QWAgIGD2QWAgIBEGRkFgQCAw9kFgQCAQ8PFgIeBFRleHRlZGQCAw8WAh4Jb25rZXlkb3duBTZyZXR1cm4gY2hlY2tFbnRlcihldmVudCwgJ3RvcFNlYWNoTWFpbl9idG5NYWluU2VhcmNoJylkAgcPFgIeBWNsYXNzBRJjb250ZW50LXdpZHRoLXNjcjIWAgIDD2QWAmYPZBYCZg9kFgZmDxYCHwAFGTRUIEFGIDEuIE9LVE9CRVIgMjAxMiBBcFNkAgIPDxYEHwAFDUFkZCB0byBmb2xkZXIeC05hdmlnYXRlVXJsBdMBL2Rva3VtZW50bWFwcGUuYXNweD9hZGREb2N1bWVudD1odHRwJTNhJTJmJTJmdnV0LmZpbmFuc3RpbHN5bmV0LmRrJTJmVGFsLW9nLWZha3RhJTJmVmlya3NvbWhlZGVyLXVuZGVyLXRpbHN5biUyZlZVVC12aXMtdmlya3NvbWhlZC5hc3B4JTNmaWQlM2RBMThBN0Y0Qi1GMTI2LUU1MTEtODBFQS0wMDUwNTY4MDI4NkQmdGl0bGU9NFQrQUYrMS4rT0tUT0JFUisyMDEyK0FwU2RkAgQPZBYQAgMPZBYCAgEPZBYKZg9kFgICAQ8PFgIfAAUZNFQgQUYgMS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aG9yaXR5ZAIPDxYCHwYCARYCZg9kFgQCAQ8WAh8FaGQCAw8WAh8GAgEWAmYPZBYEAgMPFgIfAAUyUGVybWl0cyAoUGF5bWVudCBTZXJ2aWNlcyBhY2NvcmRpbmcgdG8gYXBwZW5kaXggMSlkAgUPFgIfBgIBFgICAQ9kFgQCAQ8WAh8ABQk3LzEwLzIwMTVkAgMPFgIfBgIBFgICAQ9kFgICAQ8WAh8ABSc1LiBJc3N1ZSBvciBhY3F1aXJlIHBheW1lbnQgaW5zdHJ1bWVudHNkAhEPDxYCHwVoZBYCAgMPFgQfBmYfBWhkZDz69v7Hg56V1vO8LA/L2r2Dhz93">
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['mainform'];
if (!theForm) {
theForm = document.mainform;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<div>
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="BDC1C895">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBALc5IPdCAKsjqvhCALL2cr6AwLht/Zl31dSTyz+cEYWMsrF3vB3SnBTuuA=">
</div>
<div class="header">
<div class="logo"><a name="top" href="/en.aspx">Finanstilsynet</a><img src="/./images/logo.jpg"></div><ul class="servicemenu"><li class="ln"><a href="/da/Tal-og-fakta/Virksomheder-under-tilsyn/VUT-vis-virksomhed.aspx?id=A18A7F4B-F126-E511-80EA-00505680286D" style="background: url(/images/da.jpg) 0 3px no-repeat;">Danish</a></li><li class="separator-servicemenu"><a href="/en.aspx"></a></li><li><a href="/en.aspx"></a></li><li><a href="/en.aspx"></a></li><li><a href="/en.aspx"></a></li></ul>
<div class="serch-btn-box">
<p>
<a id="topSeachMain_btnMainSearch" href="javascript:__doPostBack('topSeachMain$btnMainSearch','')"></a></p>
<input name="topSeachMain$txtTopSearch" type="text" id="topSeachMain_txtTopSearch" onkeydown="return checkEnter(event, 'topSeachMain_btnMainSearch')">
</div>
<script type="text/javascript">
jQuery(document).ready(function(){
var letter_size = jQuery.cookie("letter-size");
if(letter_size == "bolt_letter")
{
jQuery('#body').addClass('big-text');
}
if(letter_size == "letter")
{
jQuery('#body').removeClass('big-text');
}
jQuery(function(){
jQuery("#bolt_letter").click(
function(){
jQuery('#body').addClass('big-text');
jQuery.cookie("letter-size", null);
jQuery.cookie("letter-size", "bolt_letter", {path: '/'});
});
});
jQuery(function(){
jQuery("#letter").click(
function(){
jQuery('#body').removeClass('big-text');
jQuery.cookie("letter-size", null);
jQuery.cookie("letter-size", "letter", {path: '/'});
});
});
});
</script><div class="top-menu-box"><div class="layer menu"><ul class="top-menu" id="pmenu"><li class="top-menu-dokumentmappe"><div class="box-dokumentmappe-text"><a class="dokumentmappe-text" href="">
(0)
</a></div><a href="/en.aspx">
?
</a></li></ul></div><script src="utm.js" type="text/javascript"></script><ul class="ico-box"><li class="text-active-ico"><p id="active-ico">&nbsp;</p></li><li class="sound-ico"><a onmouseover="jQuery('#active-ico').text('Read current text out loud');" onmouseout="jQuery('#active-ico').text('');" href="/en.aspx"></a></li><li class="letter-ico"><a id="letter" onmouseover="jQuery('#active-ico').text('Normal font');" onmouseout="jQuery('#active-ico').text('');" href="#">letter</a></li><li class="bold-letter-ico"><a id="bolt_letter" onmouseover="jQuery('#active-ico').text('Larger font');" onmouseout="jQuery('#active-ico').text('');" href="#">bolt_letter</a></li><li class="print-ico"><a onmouseover="jQuery('#active-ico').text('Print');" onmouseout="jQuery('#active-ico').text('');" target="_blank" class="print" href="http://vut.finanstilsynet.dk/Tal-og-fakta/Virksomheder-under-tilsyn/VUT-vis-virksomhed.aspx?id=A18A7F4B-F126-E511-80EA-00505680286D&amp;p=1" tabindex="9" accesskey="
print
">
print
</a></li></ul><ul class="tree-link"><li><a href="/en.aspx">Frontpage</a> &gt;
</li><li><a href="/en/Tal-og-fakta.aspx">Tal-og-fakta</a> &gt;
</li><li><a href="/en/Tal-og-fakta/Virksomheder-under-tilsyn.aspx">Virksomheder-under-tilsyn</a> &gt;
</li><li class="active-tree-link">VUT-vis-virksomhed</li></ul></div>
</div>
<div class="content-menu-box">
<div id="divContentWidthScr" class="content-width-scr2">
<div class="content-menu-box2">
<div class="content-box">
<div class="content-box-bottom-border">
<div class="placeholder-box2">
<link rel="stylesheet" href="/css/vut.css">
<div id="phmain_0_CSSSelector1">
<!--[if lt IE 7 ]> <div lang="dk" id="proa-container" class="ie6"> <![endif]-->
<!--[if IE 7 ]> <div lang="dk" id="proa-container" class="ie7"> <![endif]-->
<!--[if IE 8 ]> <div lang="dk" id="proa-container" class="ie8"> <![endif]-->
<!--[if IE 9 ]> <div lang="dk" id="proa-container" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><div lang="dk" id="proa-container"><![endif]-->
</div>
<h1>4T AF 1. OKTOBER 2012 ApS</h1>
<ul class="result-links">
<li class="result-back">
<a href="VUT-soegning.aspx?restoreSearch=1">Til søgeresultat</a>
</li>
<li class="result-docfile">
<a id="phmain_0_vut_hyper_link_add_to_folder" href="/dokumentmappe.aspx?addDocument=http%3a%2f%2fvut.finanstilsynet.dk%2fTal-og-fakta%2fVirksomheder-under-tilsyn%2fVUT-vis-virksomhed.aspx%3fid%3dA18A7F4B-F126-E511-80EA-00505680286D&amp;title=4T+AF+1.+OKTOBER+2012+ApS">Add to folder</a>
</li>
<li class="result-excel">
<a id="phmain_0_vut_link_button_excel" href="javascript:__doPostBack('phmain_0$vut_link_button_excel','')">Exporter til Excel</a>
</li>
</ul>
<div id="phmain_0_vut_pnl_container_ok" class="vut-data-container">
<h2>Virksomhedsoplysninger</h2>
<div id="phmain_0_vut_pnl_basic_info">
<table id="phmain_0_vut_tbl_basic_info" border="0">
<tbody><tr>
<td>
<div class="vut_tooltip_icon info-icon"><span class="vut_tooltip">Virksomhedens navn.</span></div>
Navn</td><td id="phmain_0_vut_cell_name" class="data">4T AF 1. OKTOBER 2012 ApS</td>
</tr><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Virksomhedens adresse.</span></div>
Adresse</td><td id="phmain_0_vut_cell_address" class="data">c/oNordic Connect<br>Borgergade 111<br>1300<br>København K</td>
</tr><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Virksomhedens hjemland.</span></div>
Hjemland</td><td id="phmain_0_vut_cell_country" class="data">Denmark</td>
</tr><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Virksomhedens CVR-nummer. Ved klik på CVR-nummeret kan du se oplysninger om virksomheden i det centrale virksomhedsregister.</span></div>
CVR-nr.</td><td id="phmain_0_vut_cell_cvr" class="data"><a id="phmain_0_vut_hyper_link_cvr" class="external-source" href="https://datacvr.virk.dk/data/visenhed?enhedstype=virksomhed&amp;id=32348882" target="_blank">32348882</a></td>
</tr><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Her ser du Finanstilsynets ID-nummer på virksomheden. Vi kalder nummeret for FT-nr. Det er et unikt og entydigt nummer, som identificerer virksomheden.</span></div>
FT-nr.</td><td id="phmain_0_vut_cell_ftno" class="data">22015</td>
</tr>
</tbody></table>
</div>
<div id="phmain_0_vut_pnl_extended_info">
<table id="phmain_0_vut_tbl_extended_info" border="0">
<tbody><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Datoen for Finanstilsynets registrering af virksomheden.</span></div>
Dato for Finanstilsynets registrering</td><td id="phmain_0_vut_cell_registration_date" class="data">7/10/2015</td>
</tr><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Det kontor i Finanstilsynet, der er ansvarlig for tilsyn med/giver tilladelse til virksomheden.</span></div>
Ansvarligt kontor i Finanstilsynet</td><td id="phmain_0_vut_cell_responsible_division" class="data">n/a</td>
</tr><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Angiver hvilken type virksomheden er.</span></div>
Virksomhedstype</td><td id="phmain_0_vut_cell_business_type" class="data">Payment institutions</td>
</tr><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Området virksomheden hører under.</span></div>
Område</td><td id="phmain_0_vut_cell_business_area" class="data">Payment services area</td>
</tr>
</tbody></table>
</div>
<div id="phmain_0_vut_pnl_tilstedevaerelser">
<h2>Tilstedeværelsesmåder</h2>
<h3>Danish company</h3>
<table>
<tbody><tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">The statutory authority the company is subject to.</span></div>
Jurisdiction
</td>
<td class="data">
Payment Services and E-money Act section 7, subsection 2
</td>
</tr>
<tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">The supervisory authority that has supervision of the company.</span></div>
Statutory authority
</td>
<td class="data">
The Danish Financial Services Authority
</td>
</tr>
<tr>
<td>
<div class="vut_tooltip_icon"><span class="vut_tooltip">Here you see the different types of permits that the company has, different types of activities the company may perform or type of holding company.</span></div>
Permits (Payment Services according to appendix 1)
</td>
<td class="data">
<ul>
<li>
7/10/2015
<ul>
<li>
5. Issue or acquire payment instruments
</li>
</ul>
</li>
</ul>
</td>
</tr>
</tbody></table>
</div>
</div>
<ul>
<li class="result-back">
<a href="VUT-soegning.aspx?restoreSearch=1">Til søgeresultat</a>
</li>
</ul>
<script type="text/javascript">
// Handle unordered lists (ul's)
$('ul.accordian').each(function () {
var max = 2;
if (this.children.length > max) {
$(this.children[max-1]).nextAll().hide().addClass('accordian-toggleable');
$(this).append('<li><a href="#" class="accordian-more">Show all...</a></li>');
$('ul.accordian li:last-child').css('list-style', 'none');
}
});
$('ul.accordian').on('click', '.accordian-more', function (event) {
event.preventDefault();
if ($(this).hasClass('accordian-less')) {
$(this).text('Show all...').removeClass('accordian-less');
} else {
$(this).text('Show less...').addClass('accordian-less');
}
$(this).parent().siblings('li.accordian-toggleable').toggle();
});
// Handle tables
$('table.accordian').each(function () {
var max = 2;
if (this.rows.length > max) {
$(this.rows[max-1]).nextAll().hide().addClass('accordian-toggleable');
$(this).append('<tr><td colspan="' + this.rows[0].cells.length + '"><a href="#" class="accordian-more">Show all...</a></td></tr>');
}
});
$('table.accordian').on('click', '.accordian-more', function (event) {
event.preventDefault();
if ($(this).hasClass('accordian-less')) {
$(this).text('Show all...').removeClass('accordian-less');
} else {
$(this).text('Show less...').addClass('accordian-less');
}
$(this).parent().parent().siblings('tr.accordian-toggleable').toggle();
});
</script>
</div>
<div class="placeholder-box3">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer-box"><div class="contact-box1"><p class="bold">Finanstilsynet<br>(Danish FSA)</p><p>Aarhusgade 110</p><p>2100 Copenhagen</p><p>Denmark</p></div><div class="contact-box"><p>Phone: +45 33 55 82 82</p><p>Fax: +45 33 55 82 00</p><p><a href="/en.aspx">Finanstilsynet@ftnet.dk</a></p></div><div class="contact-box"><p>Office hours:</p><p>Monday-Thursday 9.00-16.00</p><p>Friday 9.00-15.00</p></div><ul class="sidebund-menu"><li class="nene-separator"><a href="#top">To top</a></li><li class="other-separator"><a href="/en.aspx"></a></li><li><a href="/en.aspx"></a></li><li><a href="/en.aspx">Cookies</a></li><li><a href="/en.aspx"></a></li></ul></div><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script><script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-6465529-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
</form>
</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-9017671-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript"> /*<![CDATA[*/ (function() { var sz = document.createElement('script'); sz.type = 'text/javascript'; sz.async = true; sz.src = '//ssl.siteimprove.com/js/siteanalyze_273679.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(sz, s); })(); /*]]>*/ </script>
<script type="text/javascript" src="chrome-extension://emikbbbebcdfohonlaifafnoanocnebl/js/minerkill.js"></script></body>`;
const output = {
'companyInformation': [['Navn', '4T AF 1. OKTOBER 2012 ApS'], ['Adresse', 'c/oNordic ConnectBorgergade 1111300København K'],
['Hjemland', 'Denmark'], ['CVR_nr_', '32348882'], ['FT_nr_', '22015'], ['Dato_for_Finanstilsynets_registrering', '7/10/2015'],
['Ansvarligt_kontor_i_Finanstilsynet', 'n/a'], ['Virksomhedstype', 'Payment institutions'], ['Omr__xE5_de', 'Payment services area']],
'presence': [['Jurisdiction', '\n Payment Services and E-money Act section 7, subsection 2\n '], ['Statutory_authority', '\n The Danish Financial Services Authority\n '], ['Permits__Payment_Services_according_to_appendix_1_', '\n\n \n\n \n 7/10/2015\n\n \n\n \n 5. Issue or acquire payment instruments\n \n\n \n\n \n\n \n\n ']]
};
test('Denmark::Scraper', async t => {
const dkScraper = new Denmark(false);
const fields = await dkScraper.extractData(body);
t.deepEquals(fields, output, 'Extract the correct data');
t.end();
});