我需要下载某个 facebook 页面的源代码。所以我想我会登录到facebook,然后下载源代码。但是关于我登录的信息完全丢失了,当我尝试从另一个 url 下载源代码时,似乎我仍然为我的应用程序注销。
所以这是我的代码:
public class App
{
public static void main( String[] args ) throws IOException
{
System.out.println( "Hello World!" );
final WebClient webClient = new WebClient();
final HtmlPage page1 = webClient.getPage("http://www.facebook.com");
final HtmlForm form = (HtmlForm) page1.getElementById("login_form");
final HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue("Log In").get(0);
final HtmlTextInput textField = form.getInputByName("email");
textField.setValueAttribute("email");
final HtmlPasswordInput textField2 = form.getInputByName("pass");
textField2.setValueAttribute("password");
final HtmlPage page2 = button.click();
HtmlPage weread = webClient.getPage("http://apps.facebook.com/ireadit/?fb_source=bookmark_apps&ref=bookmarks&count=0&fb_bmpos=2_0");
System.out.println(weread.asXml());
}
我希望你能理解我的想法……有什么建议吗?