Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 自动化谷歌登录和下载应用统计_Java_Google Play_Htmlunit - Fatal编程技术网

Java 自动化谷歌登录和下载应用统计

Java 自动化谷歌登录和下载应用统计,java,google-play,htmlunit,Java,Google Play,Htmlunit,因此,目前我有一个抓取程序,可以登录到google帐户,从google play开发者控制台抓取应用程序数据(下载、ANR、崩溃等)。我使用java和HTMLUnit库来创建刮板。以下是登录部分的代码片段: public static void login(String url) { try { Utility.turn_off_warning(webclient); //this is just to turn off the warning in HTMLUnit

因此,目前我有一个抓取程序,可以登录到google帐户,从google play开发者控制台抓取应用程序数据(下载、ANR、崩溃等)。我使用java和HTMLUnit库来创建刮板。以下是登录部分的代码片段:

public static void login(String url)
{
  try
  {
    Utility.turn_off_warning(webclient); //this is just to turn off the warning in HTMLUnit

    HtmlPage page = (HtmlPage)webclient.getPage(url);
    //getting the elements
    HtmlTextInput email = (HtmlTextInput)page.getElementById("Email"); 
    HtmlPasswordInput pass = (HtmlPasswordInput)page.getElementById("Passwd");
    HtmlSubmitInput submit = (HtmlSubmitInput)page.getElementById("signIn");

// inserting value

    email.setValueAttribute(Settings.google_username);
    pass.setValueAttribute(Settings.google_pass);

// press login button
    HtmlPage afterLogin = (HtmlPage)submit.click();


    System.out.print("Logged In");
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
}

所以上面的代码适用于登录部分,直到几周前谷歌改变了登录页面的结构IIRC,现在你必须先输入电子邮件,按下下一步按钮,输入密码,然后按下登录按钮。我试着让我的铲运机完全做到这一点,但没有成功。我猜这是因为页面中javascript的任何更改都不能由HTMLUnit处理,所以现在我被卡住了。非常感谢您的任何帮助或建议。。。谢谢:)

好的,我找到了解决办法

 webclient.setJavaScriptEnabled(false);
我添加了这一行,它很有效。我只需要改变流量从

grabbing all elements -> set all value -> click submit

grab email input and submit button -> set email -> 
submit -> grab password and submit button -> set password -> submit