Java Code Examples for edu.uci.ics.crawler4j.crawler.CrawlConfig#addAuthInfo()

The following examples show how to use edu.uci.ics.crawler4j.crawler.CrawlConfig#addAuthInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrawlControllerFactory.java    From vividus with Apache License 2.0 6 votes vote down vote up
private CrawlConfig createCrawlConfig(URI mainApplicationPage)
{
    CrawlConfig crawlConfig = new CrawlConfig();
    crawlConfig.setCrawlStorageFolder(crawlStorageFolder);
    crawlConfig.setPolitenessDelay(0);
    crawlConfig.setSocketTimeout(SOCKET_TIMEOUT);
    crawlConfig.setRespectNoFollow(false);
    crawlConfig.setRespectNoIndex(false);

    UserInfo userInfo = UriUtils.getUserInfo(mainApplicationPage);
    if (userInfo != null)
    {
        try
        {
            BasicAuthInfo authInfo = new BasicAuthInfo(userInfo.getUser(), userInfo.getPassword(),
                    UriUtils.removeUserInfo(mainApplicationPage).toString());
            crawlConfig.addAuthInfo(authInfo);
        }
        catch (MalformedURLException e)
        {
            throw new IllegalArgumentException(e);
        }
    }
    return crawlConfig;
}
 
Example 2
Source File: Crawler.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
public Crawler(File storing, List<String> urlSeeds, int maxDept, int maxPages,String loginURL, String username, String password, String usernameFieldName, String passwordFieldName) throws MalformedURLException
{
	logger = (OssmeterLogger) OssmeterLogger.getLogger("nlp.tools.webcrawler");
	CrawlConfig config = new CrawlConfig();
	config.setIncludeHttpsPages(true);
	config.setPolitenessDelay(1000);
	config.setCrawlStorageFolder(storing.toString());
	config.setMaxDepthOfCrawling(maxDept);
	config.addAuthInfo(createAuthethicator(username, password, loginURL, usernameFieldName, passwordFieldName));
       config.setMaxPagesToFetch(maxPages);       
       
       createCrawler(config, storing, urlSeeds);
}
 
Example 3
Source File: Crawler.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
public Crawler(File storing, List<String> urlSeeds, String loginURL, String username, String password, String usernameFieldName, String passwordFieldName) throws MalformedURLException
{
	logger = (OssmeterLogger) OssmeterLogger.getLogger("nlp.tools.webcrawler");
	CrawlConfig config = new CrawlConfig();
	config.setIncludeHttpsPages(true);
	config.setPolitenessDelay(1000);
	config.setCrawlStorageFolder(storing.toString());
	config.setMaxDepthOfCrawling(-1);
       config.setMaxPagesToFetch(-1);       
       config.addAuthInfo(createAuthethicator(username, password, loginURL, usernameFieldName, passwordFieldName));
       createCrawler(config, storing, urlSeeds);
}