3

I have seen this asked before and seen many answer "there is a facebook api" yes I am fully aware there is a facebook api but I do not wish to use it. I am making an android app that can login to sites and post, I am simply using a facebook example to illustrate my problem

I have this code in java

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;


public class testingjsoup {

public static void main(String[] args ){




try {
    Connection.Response res = Jsoup.connect("https://www.facebook.com/login.php?login_attempt=1")
            .data("email", "myemailid", "pass", "mypassword")
            .method(Method.POST)
            .execute();
//  Document doc = res.parse();
    //String sessionId = res.cookie("SESSIONID");


    Map<String, String> cookies = res.cookies();



    Document doc2 = Jsoup.connect("https://www.facebook.com/")
            .cookies(cookies)
            .get();

    System.out.println(doc2.text());
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}



}}

now it all looks well and good except that the print out shows that facebook is saying that "javascript is not enabled"

thank you

code updated as well as problem :P

edit: seems like jsoup does not support javascript... so looking for alternatives... again html unit does not work with android and I am not looking for a web driver I am looking for an invisible way to browse the web and return specific results

Joe Yahchouchi
  • 627
  • 7
  • 16

1 Answers1

5

Look a this post.

You can also use HttpClient or URLConnection to manage your connections and http request and use JSOUP only for parsing.

Community
  • 1
  • 1
lujop
  • 13,504
  • 9
  • 62
  • 95