0

嗨,我想知道当输入错误的电子邮件或密码时,是否有人可以帮助我使用来自 facebook 的 jsoup 获取 URL。我不知道如何获取网址,但我可以获取文本。

这是我的代码:

package com.sigustgebran.appsl;

import android.os.Bundle;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;

public class MainAct extends Activity {


TextView display;
String anerror = "error";
// facebook url
    static final String FACE_URL = "https://www.facebook.com/";


@Override
protected void onCreate(Bundle savedInstanceState) {
    // set layout view
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_main);
    display = (TextView) findViewById(R.id.tvDisplay);
    // process
    try {
        display.setText(logfail());
    } catch (Exception ex) {
        display.setText(anerror);
    }


}



protected String logfail() throws Exception {
    String result = "";

    Document document = Jsoup.connect(FACE_URL)
            .data("lsd", "AVrzRTqK")
            .data("email", "xxxxx") 
            .data("pass", "xxxxx") 
            .data("u_0_b", "Logga in") 
            .data("persistent", "1")
            .data("default_persistent", "0")
            .data("timezone", "-120")
            .data("lgnrnd", "145445_r4qy")
            .data("lgnjs", "1369864484")
            .data("locale", "sv_SE")
            .post();

        result = document.text();

    // return
    return result;
}



@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

谢谢!!

4

1 回答 1

0

请参考这个 URL,你知道如何获取 URL

http://jsoup.org/cookbook/extracting-data/example-list-links

您还可以通过 url 向 Jsoup 解析器发送:

   Document doc = Jsoup.connect("http://en.wikipedia.org/").get();
于 2013-05-30T09:09:01.780 回答