0

jaunt-api を使用して yahoo メールにログインしようとしていますが、「cookie が有効になっていない問題」が発生します。私はjaunt-apiが初めてなので、助けてください。次のコードを使用しています。

try
{
UserAgent userAgent = new UserAgent();
            userAgent.setCacheEnabled(false);
            userAgent.settings.autoSaveAsHTML = true;
            try{
                userAgent.cookieJar.saveCookies(new File("e:\\cookie.txt"));
            }catch(Exception e){}
            userAgent.visit("https://login.yahoo.com/m");                        

            try{
            userAgent.cookieJar.loadCookies(new File("e:\\cookie.txt"));
            }catch(Exception e){}

            Form form = userAgent.doc.getForm(0);
            form.setTextField("username", "*****@gmail.com");
            form.setPassword("passwd", "*******");
            form.submit();
            System.out.println(userAgent.doc.innerHTML());
            System.out.println(userAgent.getLocation());
        }catch(JauntException e){
            System.out.println(e);
        }
4

1 に答える 1

0

Cookie をテキスト ファイルから Jaunt に読み込むことはできません。以前に Cookie を保存するために使用したのと同じファイルを指定する必要があります。(Jaunt は Cookie コンテナ オブジェクトをシリアライズしているため、それが .txt ファイルの内容でない限り、機能しません)。

于 2016-02-10T21:39:52.877 に答える