【发布时间】:2016-03-02 21:52:39
【问题描述】:
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('https://www.tumblr.com/login');
driver.findElement(webdriver.By.id('signup_email')).sendKeys('my_username');
driver.findElement(webdriver.By.id('signup_password')).sendKeys('my_password');
driver.findElement(webdriver.By.id('signup_forms_submit')).click();
driver.wait(function(){
driver.get('https://www.tumblr.com/search/love+gifs');
},5000);
driver.wait(function(){
driver.findElement(webdriver.By.id("post_control like")).click();
},1000);
driver.wait(function(){
driver.findElement(webdriver.By.id("follow-text")).click();
},1000);
driver.quit();
<div class="post-info-post-tumblelog">
<div class="post-info-tumblelog">
<a class="follow_link worded-follow-button show-unfollow" data-subview="follow" href="/follow/pleasingpics" style="width: 41px;">
<div class="follow-text" title="Follow">Follow</div>
<div class="unfollow-text" title="Unfollow">Unfollow</div>
</a>
</div>
</div>
我有一个 Javascript 代码,用于使用 Selenium WebDriver 在 Tumblr 上跟踪一些帐户。
在 HTML 代码中,您可以在名为“follow-text”的类中看到一个关注按钮。但是我的代码不起作用,我也想知道跟随按钮实际上不是一个按钮,但他们已经把它变成了一个可点击的 div 类。我对 HTML/CSS 不太熟悉,而且我是 Javascript 和 Selenium Webdriver 的新手。我的代码有什么问题?此外,我必须单击同一页面上不同帖子上的关注按钮。我正在考虑创建一个循环,但我什至无法单击其中一个。任何帮助将不胜感激。
【问题讨论】:
-
这里不是最重要的,但很确定这会违反 Tumblr 的 T's & C's: "... 或超载服务,或通过脚本使用服务这种方式会干扰服务或给服务造成不适当的负担。” - 每秒 1 次关注可能被视为垃圾邮件/负担。
-
我不知道条款和条件,但这是我实习计划的一部分,这就是我这样做的原因,因为这对我很重要。操作之间的时间可能会超过 1 秒,但无论如何,感谢您的评论。
-
如果是实习,他们要求你这样做,要么故意违反规则,要么在不知情的情况下 - 这是一个不好的迹象。
标签: javascript node.js selenium selenium-webdriver