【问题标题】:how to make a javascript program that scans a website for a link如何制作一个扫描网站链接的javascript程序
【发布时间】:2014-01-01 03:27:55
【问题描述】:

我需要一个扫描网站以查找链接的程序。这是我到目前为止所拥有的,但它不会自动单击或查找链接,它只是刷新页面。你们能否修复代码中的错误或告诉我如何修复它们?顺便说一句,此代码用于刷新 nike 的 twitter 提要的机器人,然后在链接出现后立即自动点击链接。 “var shoeName”是鞋子的名称。谢谢

var shoeName = "Nike Flyknit Max";
var nikestore = "nikestore";
var closeFlag = "no";
var tFunction = "twitterScan()";
var tweet = new Array();
var tweetName = new Array();

function twitterScan() {

for (var i = 0; i < 4; i++) {
    tweetName[i] = document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;
    tweet[i] = document.getElementsByClassName("js-tweet-text")[i].innerHTML;

}


//if (document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;

if (tweet[0].match(shoeName) == shoeName) {
    document.getElementsByClassName("twitter-timeline-link")[0].click();
    tFunction = "get outa here";
    shoeName = " 4444  4 456 7 8 456 7 345 7 345  345 3 1 1 133s "; //buffer to jump out of interval loop

} 

else if (tweet[1].match(shoeName) == shoeName) {
    document.getElementsByClassName("twitter-timeline-link")[1].click();
    tFunction = "get outa here";
    shoeName = " 4444  4 456 7 8 456 7 345 7 345  345 3 1 1 133s "; //buffer to jump out of interval loop

}

else if (tweet[2].match(shoeName) == shoeName) {
    document.getElementsByClassName("twitter-timeline-link")[2].click();
    tFunction = "get outa here";
    shoeName = " 4444  4 456 7 8 456 7 345 7 345  345 3 1 1 133s "; //buffer to  jump out of interval loop

}


else if (tweet[3].match(shoeName) == shoeName) {
    document.getElementsByClassName("twitter-timeline-link")[3].click();
    tFunction = "get outa here";
    shoeName = " 4444  4 456 7 8 456 7 345 7 345  345 3 1 1 133s "; //buffer to         jump out of interval loop

}


else {
    location.reload(true);
}

setTimeout(tFunction, 250);


}

setTimeout(tFunction, 250);

//setInterval("refreshPage()", 3000);
//setTimeout("twitterScan()", 100);
//setInterval(tFunction, 700);

【问题讨论】:

  • 您是否尝试将此代码应用到属于其他人的网页,而不编写这是他们的源代码?我不确定这是否可能。

标签: javascript html search hyperlink


【解决方案1】:

twitterScan 方法中,您尝试存储元素的interHTML,我们假设它们是鞋名。

for (var i = 0; i < 4; i++) {
        tweetName[i] = document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;
        tweet[i] = document.getElementsByClassName("js-tweet-text")[i].innerHTML;

    }

之后,如果它们恰好匹配,您将单击鞋子名称链接。看起来不错,但是如果您让我们知道您的整个应用程序的流程,那就太好了。

根据您所说,您的应用代码与任何鞋名都不匹配,而是在重新加载您的页面本身。然后,它不匹配任何具有这些类名的元素。 脚本中提到的元素具体在哪里?

【讨论】:

    【解决方案2】:

    您正在寻找推特扫描仪。比较容易。主要是 document.getElement

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-16
      • 2013-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 2014-11-20
      相关资源
      最近更新 更多