火车采集器软件交流官方论坛

 找回密码
 加入会员
搜索
火车采集器V9版免费下载火车浏览器 - 可视采集,万能群发,全自动脚本工具
查看: 2532|回复: 3

求助,源文件里用javascript得来的数据怎么采集啊

[复制链接]
发表于 2012-11-17 23:42:23 | 显示全部楼层 |阅读模式
要采集这个网站http://www.okooo.com/match/1/211466/history/
采集数据为: 5胜4平1负,其中主场2胜2平0负
源文件里用 javascript得来的,我不懂啊。各路大神来拯救下吧。
 楼主| 发表于 2012-11-18 09:39:25 | 显示全部楼层
路过的大神啊,帮看看呀
发表于 2012-11-18 15:43:19 | 显示全部楼层
  1. $().ready(function () {
  2.     var homecompobj = $(".homecomp");
  3.     var awaycompobj = $(".awaycomp");
  4.     var vscompobj = $(".vscomp");
  5.     var hometrobj = homecompobj.find("tr");
  6.     var awaytrobj = awaycompobj.find("tr");
  7.     var vstrobj = vscompobj.find("tr");
  8.     var teamname = 0;
  9.     var homeindex = 2;
  10.     var awayindex = 4;
  11.     var recordindex = 3;
  12.     if (GetCookie('historyShowThisMatch') == 1) {
  13.         $('#jsSetVisible').attr('checked', true);
  14.         $('.jsThisMatch').show();
  15.     } else {
  16.         $('#jsSetVisible').attr('checked', false);
  17.         $('.jsThisMatch').hide();
  18.     }
  19.     $('#jsSetVisible').click(function () {
  20.         if (this.checked) {
  21.             SetCookie('historyShowThisMatch', 1, 100 * 24 * 60 * 60, '/');
  22.             $('.jsThisMatch').show();
  23.             google_p([action, '选择包含本场']);
  24.         } else {
  25.             SetCookie('historyShowThisMatch', 0, 100 * 24 * 60 * 60, '/');
  26.             $('.jsThisMatch').hide();
  27.             google_p([action, '取消包含本场']);
  28.         }
  29.     })

  30.     function gethomerecord(team, returnid, trobj) {
  31.         var victory = 0;
  32.         var failure = 0;
  33.         var draw = 0;
  34.         var homevictory = 0;
  35.         var homefailure = 0;
  36.         var homedraw = 0;
  37.         for (var i = 3, ilen = trobj.length; i < ilen; i++) {
  38.             if ($(trobj[i]).css("display") == "none") continue;
  39.             var datasarr = $(trobj[i]).attr("attr").split(",");
  40.             var recordval = datasarr[1];
  41.             if (recordval == "-") continue;
  42.             var recordarr = recordval.split("-");
  43.             var homescore = Number(recordarr[0]);
  44.             var awayscore = Number(recordarr[1]);
  45.             var homeid = $(trobj[i]).find("td").eq(homeindex).attr("attr");
  46.             var awayid = $(trobj[i]).find("td").eq(awayindex).attr("attr");
  47.             if (returnid == homeid) {
  48.                 var checkscore = homescore - awayscore;
  49.                 if (checkscore > 0) {
  50.                     homevictory++;
  51.                 } else if (checkscore < 0) {
  52.                     homefailure++;
  53.                 } else if (checkscore == 0) {
  54.                     homedraw++
  55.                 }
  56.             } else if (returnid == awayid) {
  57.                 var checkscore = awayscore - homescore;
  58.             }
  59.             if (checkscore > 0) {
  60.                 victory++;
  61.             } else if (checkscore < 0) {
  62.                 failure++;
  63.             } else if (checkscore == 0) {
  64.                 draw++
  65.             }
  66.         }
  67.         if (team != "away") {
  68.             var gethtml = victory + "胜" + draw + "平" + failure + "负,其中主场" + homevictory + "胜" + homedraw + "平" + homefailure + "负";
  69.         } else {
  70.             var gethtml = victory + "胜" + draw + "平" + failure + "负,其中客场" + (victory - homevictory) + "胜" + (draw - homedraw) + "平" + (failure - homefailure) + "负";
  71.         }
  72.         return gethtml;
  73.     }

  74.     function getscorehtml(team, returnid, trobj) {
  75.         $("." + team + "score").html(gethomerecord(team, returnid, trobj));
  76.     }
  77.     getscorehtml("home", host_team_id, hometrobj);
  78.     getscorehtml("away", guest_team_id, awaytrobj);
  79.     getscorehtml("vs", host_team_id, vstrobj);
  80.     $("#HomeLeagueFilter").change(function () {
  81.         filter(hometrobj, "Home", host_team_id, $(this));
  82.         getscorehtml("home", host_team_id, hometrobj);
  83.     });
  84.     $("#HomeFilter").change(function () {
  85.         filter(hometrobj, "Home", host_team_id, $(this));
  86.         getscorehtml("home", host_team_id, hometrobj);
  87.     });
  88.     $("#HomeCount").change(function () {
  89.         filter(hometrobj, "Home", host_team_id, $(this));
  90.         getscorehtml("home", host_team_id, hometrobj);
  91.     });
  92.     $("#AwayLeagueFilter").change(function () {
  93.         filter(awaytrobj, "Away", guest_team_id, $(this));
  94.         getscorehtml("away", guest_team_id, awaytrobj);
  95.     });
  96.     $("#AwayFilter").change(function () {
  97.         filter(awaytrobj, "Away", guest_team_id, $(this));
  98.         getscorehtml("away", guest_team_id, awaytrobj);
  99.     });
  100.     $("#AwayCount").change(function () {
  101.         filter(awaytrobj, "Away", guest_team_id, $(this));
  102.         getscorehtml("away", guest_team_id, awaytrobj);
  103.     });
  104.     $("#VsLeagueFilter").change(function () {
  105.         filter(vstrobj, "Vs", host_team_id, $(this));
  106.         getscorehtml("vs", host_team_id, vstrobj);
  107.     });
  108.     $("#VsFilter").change(function () {
  109.         filter(vstrobj, "Vs", host_team_id, $(this));
  110.         getscorehtml("vs", host_team_id, vstrobj);
  111.     });
  112.     $("#VsCount").change(function () {
  113.         filter(vstrobj, "Vs", host_team_id, $(this));
  114.         getscorehtml("vs", host_team_id, vstrobj);
  115.     });

  116.     function filter(trobj, team, idval, curobj) {
  117.         var teamval = $("#" + team + "LeagueFilter").val();
  118.         var haval = $("#" + team + "Filter").val();
  119.         var conval = $("#" + team + "Count ").val();
  120.         var checki = 0;
  121.         for (var i = 3, ilen = trobj.length; i < ilen; i++) {
  122.             var teamtext = $(trobj[i]).find("td").eq(teamname).text().trim();
  123.             var datasarr = $(trobj[i]).attr("attr").split(",");
  124.             var homeid = datasarr[0];
  125.             var awayid = datasarr[2];
  126.             var isFriendly = $(trobj[i]).attr('data-lt');
  127.             if (teamval == 'notFriendly' && isFriendly == 'friend') {
  128.                 $(trobj[i]).hide();
  129.                 continue;
  130.             }
  131.             if (teamval != "all" && teamval != 'notFriendly' && teamtext != teamval) {
  132.                 $(trobj[i]).hide();
  133.                 continue;
  134.             }
  135.             if (haval != "all" && haval == "Away") {
  136.                 if (awayid != idval) {
  137.                     $(trobj[i]).hide();
  138.                     continue;
  139.                 }
  140.             } else if (haval != "all" && haval == "Home") {
  141.                 if (homeid != idval) {
  142.                     $(trobj[i]).hide();
  143.                     continue;
  144.                 }
  145.             }
  146.             checki++;
  147.             if (checki > Number(conval)) {
  148.                 $(trobj[i]).hide();
  149.                 continue;
  150.             }
  151.             $(trobj[i]).show();
  152.         }
  153.         google_p([action, team + $('option:selected', curobj).text()]);
  154.     }
  155. });

  156. function showTable(ID, TotalCount) {
  157.     for (var I = 1; I <= TotalCount; I++) {
  158.         if (I == ID) {
  159.             document.getElementById("Table" + I).style.display = "";
  160.         } else {
  161.             document.getElementById("Table" + I).style.display = "none";
  162.         }
  163.     }
  164. }
复制代码
关键代码,这个是利用jQuery动态生成的,十分难搞啊……

http://img1.okoooimg.com/min/?b=JS&f=dataanalysis%2ffootcompetitionhistory.js&v=201211151048
 楼主| 发表于 2012-11-18 19:18:47 | 显示全部楼层
塞北的雪 发表于 2012-11-18 15:43
关键代码,这个是利用jQuery动态生成的,十分难搞啊……

http://img1.okoooimg.com/min/?b=JS&f=dataana ...

多谢了,十二分感谢!
这个问题看来确实是很难了
您需要登录后才可以回帖 登录 | 加入会员

本版积分规则

QQ|手机版|Archiver|火车采集器官方站 ( 皖ICP备06000549 )

GMT+8, 2025-7-3 19:12

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表