我想编写一个爬虫来爬取 facebook 用户的帖子,以便在我的研究中进行分析。我用谷歌搜索了一些推荐的方法,然后我用这个代码登录 facebook
public class fbcrawler {
public static void main(String[] args) throws Exception{
String email ="";
String pwd = "";
//1. Login Facebook
WebClient webClient = new WebClient(BrowserVersion.CHROME);
HtmlPage page = webClient.getPage("http://www.facebook.com");
HtmlTextInput emailInput = (HtmlTextInput)page.getElementById("email");
emailInput.setValueAttribute(email);
HtmlPasswordInput passInput = (HtmlPasswordInput)page.getElementById("pass");
passInput.setValueAttribute(pwd);
HtmlSubmitInput submitBtn =(HtmlSubmitInput)page.getElementById("loginbutton").getFirstChild();
HtmlPage mainPage = submitBtn.click();
String pageAsXml = mainPage.asXml();
System.out.println(pageAsXml);
使用此代码可以登录facebook,但如果我不翻页,我只能抓取网页上的前几个数据,请帮助我使用htmlunit在facebook中翻页