简体   繁体   English

如何使用JSoup登录网站并提取数据?

[英]How to login to a website and extract data using JSoup?

I'm trying to extract data from fantasy.premierleague.com/transfers 我正在尝试从Fantasy.premierleague.com/transfers中提取数据

Using JSoup and the following code, I can extract links from the homepage. 使用JSoup和以下代码,我可以从主页中提取链接。 However, to access the transfers page, I need to log in. 但是,要访问转移页面,我需要登录。

What should I add to this simple code so that I can login and access the transfers page? 我应该在此简单代码中添加些什么,以便登录和访问转账页面?

public class StatsCollector {

public static void main (String [] args){

    try {
        Document doc = Jsoup.connect("http://fantasy.premierleague.com/transfers").get();
        Elements links = doc.select("a[href]");
        System.out.println(links);
    }  

    catch (IOException ex) {
        Logger.getLogger(StatsCollector.class.getName()).log(Level.SEVERE,null,ex);
    }
}

} }

JSoup只是HTML解析器,您需要认证的是一些HTMLClient(例如Selenium),它可以在页面上执行某些操作(写入文本字段,单击按钮)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM