【问题标题】:Selenium WebDriver Bot for Instagram用于 Instagram 的 Selenium WebDriver Bot
【发布时间】:2016-06-01 19:31:37
【问题描述】:

我正在尝试开发一个简单的机器人,它喜欢来自特殊标签的 Instagram 图片。我正在使用 Selenium,但“单击图片”操作存在问题。登录和搜索主题标签有效。 xpath 是正确的,但是当我运行程序时它没有找到它。

public void like() {
        driver.findElement(By.xpath(".//*[@id='react-root']/section/main/article/div[2]/div[1]/div[2]/a[1]/div[2]"))
                .click();

    }

【问题讨论】:

  • 您是否尝试过使用来自 instagram 的模拟数据的程序只是为了排除这不是 API 问题?
  • 我没有使用 API,因为我不了解那个 atm。

标签: selenium webdriver instagram bots


【解决方案1】:

点击后功能:

for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (isElementPresent((By.xpath(".//*[@id='react-root']/section/main/article/div[2]/div[1]/div[2]/a[1]/div[2]")))) break; } catch (Exception e) {}
        Thread.sleep(1000);
    }

【讨论】:

    猜你喜欢
    • 2020-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-29
    • 1970-01-01
    相关资源
    最近更新 更多