1. 程式人生 > >Java網路爬蟲crawler4j學習筆記 BasicAuthInfo類

Java網路爬蟲crawler4j學習筆記 BasicAuthInfo類

原始碼

package edu.uci.ics.crawler4j.crawler.authentication;

import javax.swing.text.html.FormSubmitEvent.MethodType;
import java.net.MalformedURLException;

/**
 * Created by Avi Hayun on 11/25/2014.
 *
 * BasicAuthInfo contains the authentication information needed for BASIC authentication (extending AuthInfo which has all common auth info in it)
 *
 * BASIC authentication in PHP:
 * <ul>
 *  <li>http://php.net/manual/en/features.http-auth.php</li>
 *  <li>http://stackoverflow.com/questions/4150507/how-can-i-use-basic-http-authentication-in-php</li>
 * </ul>
 */
public class BasicAuthInfo extends AuthInfo { /** * Constructor * * @param username Username used for Authentication * @param password Password used for Authentication * @param loginUrl Full Login URL beginning with "http..." till the end of the url * * @throws MalformedURLException Make sure your URL is valid */
public BasicAuthInfo(String username, String password, String loginUrl) throws MalformedURLException { //使用get方法,進行basic登入驗證 super(AuthenticationType.BASIC_AUTHENTICATION, MethodType.GET, loginUrl, username, password); } }