2017-03-17 47 views
0

你好,我正在尝试编写一个代码,当我给出一个URL时,我将从网站上导出电话号码。但是,此代码显示网站内的所有号码,如何修改此代码以检索英国电话号码?。任何帮助,建议或批评表示赞赏。受此启发http://www.convertcsv.com/phone-extractor.htm
代码显示在下面,谢谢。Json Regex字符串电话号码导出

<script> 
    function assignText(s) { 
     document.getElementById('txt1').value = s; 
    } 
    function runit(s) { 
    eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('5 t,j,k,v;5 B=3.6("V").l;5 z=3.6("W").l;5 a=[];5 m=3.6("T").l;5 E=3.6("R").l;5 h="Y";5 e=4;7(3.6("x")){e=3.6("x").9;7(11(e))e=4;J e*=1}5 r={};r.C=L 10("\\\\+?\\\\(?\\\\d*\\\\)? ?\\\\(?\\\\d+\\\\)?\\\\d*([\\\\s./-]\\\\d{2,})+","g");5 c=3.6("G").9*1||1;7(c<1)c=1;5 8=P(3.N[0].K);7(8=="o")8=3.6("M").9;7(!8)8=",";5 A=r.C;5 a=s.O(A)||[];a=p.I(a,D(f){F f.w()});a=p.H(a,D(f){F f.X().w().q>=e&&!(/\\d\\d\\d\\d-\\d\\d-\\d\\d/.Z(f))});7(z)a=a.12();7(B)a=p.13(a,Q);3.6(\'i\').9="";5 b=[];7(m&&c>1){b.y(h+"1");u(j=2;j<=c;j++){b.y(h+j)}h=b.S(8)}7(m){3.6(\'i\').9+=h+"\\n"}u(j=0;j<a.q;){u(k=0;k<c;k++,j++){7(j<a.q){v=a[j].w();7(E)v=v.U(8);3.6(\'i\').9+=v}7(k<c-1){3.6(\'i\').9+=8}}3.6(\'i\').9+="\\n"}',62,66,'|||document||var|getElementById|if|delimiter|value|||cols||minLen|||heading|txta|||checked|hdr|||_|length|res|||for||trim|txtMinLen|push|sorted|re|dup|phone|function|forceCsv|return|txtNumCols|filter|map|else|outsep|new|outSepOtherVal|forms|match|radiovalue|true|chkForceCsv|join|chkCsvHeader|toCsv|chkDup|chkSort|removePunctuation|Phone|test|RegExp|isNaN|sort|uniq'.split('|'),0,{})) 

    } 


    </script> 

回答

0

你可以尝试使用谷歌的libphonenumber,它有一个JavaScript实现:

https://github.com/googlei18n/libphonenumber

图书馆有一个名为解析

parse(text, options) 

文本参数功能将是你的电话号码,在选项参数中,您可以输入country code。当图书馆能够将该号码解析为英国电话号码时,您知道号码是有效的。