如何制作一个扫描网站链接的JavaScript程序

时间:2014-01-01 03:27:56

标签: javascript html search hyperlink

我需要一个扫描网站链接的程序。这是我到目前为止,但它没有自动点击或找到链接,它只是刷新页面。你们可以修复代码中的eroors或者告诉我如何修复它们吗?顺便说一句,这段代码用于机器人刷新nike的twitter feed,然后一出现就自动点击链接。 “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);

2 个答案:

答案 0 :(得分:1)

twitterScan方法中,您试图存储元素的innterHTML,我们假设它们是鞋子名称。

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;

    }

之后,如果碰巧匹配,则点击鞋子名称链接。这看起来还不错,但如果你让我们知道你的整个应用程序的流程会很好。

根据您的说法,您的应用代码与任何鞋子名称都不匹配,但正在重新加载您的网页本身。然后,它不匹配任何元素与这些类名。 您的脚本中提到的元素究竟在哪里?

答案 1 :(得分:0)

您正在寻找推特扫描仪。相当容易。它主要是document.getElement