1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
(function () { 'use strict'; var $ = $ || window.$; function sleep(numberMillis) { var now = new Date(); var exitTime = now.getTime() + numberMillis; while (true) { now = new Date(); if (now.getTime() > exitTime) return; } } var enterpriseList = [ ]; var dataList = []; var errorListIds = []; GM_xmlhttpRequest({ method: 'GET', url: "http://xxx.xxxxxx.com/yyyyyy/queryEnterpriseList?startID=44633&endID=45000", headers: { "Content-Type": "application/json" }, onload: function(response) { enterpriseList = $.parseJSON( response.responseText ); getData(); }, });
var count = 0; function saveData(data){ GM_xmlhttpRequest({ method: 'POST', data:JSON.stringify(data), url: "http://xxx.xxxxx.com/yyyyyy/saveDataList", dataType: "json", headers: { "Content-Type": "application/json" }, onload: function(response) { }, }); }
function getData(){ for(var i=0;i<enterpriseList.length;i++){ var one = {}; var url = 'https://www.uuuuuuuuu.com/search?key='+enterpriseList[i].enterpriseName.replace("(","(").replace(")",')'); try{ var num=Math.floor(Math.random()*10+5); sleep(num*1000); $.ajax({url:url, async:false, success:function(data){ var str = "index_verify?type=companysearch" if(data.indexOf(str) != -1){ i = enterpriseList.length; console.log('****************************************操作需要验证'); }
var el = $( '<div></div>' ); el.html(data); var tda= $("div.content div.header a.name em", el) ; var detailUrl = $("div.content div.header a.name ", el) ;
if(tda.length >0 && tda[0].innerText == enterpriseList[i].enterpriseName){ $.ajax({url:detailUrl[0].href, async:false, success:function(data){ var el = $( '<div></div>' ); el.html(data);
one.enterpriseName = enterpriseList[i].enterpriseName ;
var tr = $("#_container_baseInfo table.table.-striped-col.-border-top-none tr", el); if(businessTerm.length>8){ if(businessTerm.substring(0,3) != '***'){ one.startTime = businessTerm.substring(0,9) ; if(businessTerm.substr(11) == '无固定期限'){ one.endTime = '2099-12-31'; }else{ one.endTime = businessTerm.substr(11); } }else{ one.startTime = td[12].innerText.replace(/\s+/g,"").replace(/[\n\r]/g,'') ; if(businessTerm.substr(4) == '无固定期限'){ one.endTime = '2099-12-31'; }else{ one.endTime = businessTerm.substr(4); } } } }, error:function(data){}}); }else{ one.qualificationNo = '--'; } dataList.push(one); if(dataList.length == 10){ saveData(dataList); dataList = []; count += 10; console.log('已保存数据:'+count); } }, error:function(data){ }}); }catch(e){ } } } })();
|