java爬虫环境库

本文详细介绍了一款Java HTTP客户端的配置参数,并列举了多种浏览器的UserAgent字符串,包括主流的桌面浏览器及部分移动端设备。这些信息对于进行网页爬虫开发或是HTTP请求定制非常有用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

package com.thesys.spider.util.http.bean;

import java.util.Random;

/**
 * 环境库
 * 该Bean仅配置偶尔变动的
 * @author Erciyns
 */
public class VbBean {

    /**
     * 是否自动转发
     * 例如:HTTP : 301 
     */
    public static final boolean ISREDIRECT = false;

    /**
     * 默认50000/ms
     * 用于大form读取传输。
     * 多用于文件、图片读取等
     */
    public static final String DEFAULT_CHARSET = "UTF-8";

    /**
     * 等待:默认1000/ms
     */
    public static final long SLEEP_FIXEDTIME = 3000;

    /**
     * 默认35000/ms
     * 用于小form读取传输。
     */
    public static final int MIN_TIMEOUT = 55000;

    /**
     * 默认50000/ms
     * 用于大form读取传输。
     * 多用于文件、图片读取等
     */
    public static final int MAX_TIMEOUT = 60000;

    /**
     * FireFox
     * 1
     */
    public static final String USERAGENT_PC_FIREFOX = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0";

    /**
     * Microsoft Edge
     * 1
     */
    public static final String USERAGENT_PC_EDGE = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063";

    /**
     * Internet Explorer
     * 1
     */
    public static final String USERAGENT_PC_IE = "Mozilla/5.0 (Wnidows NT 10.0; WOW64; Trident/7.0; vr:11.0) like Gecko";

    /**
     * UC浏览器
     * 1
     */
    public static final String USERAGENT_PC_UC = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.3637.802 Safari/537.36";

    /***
     * 搜狗高速浏览器
     * 1
     */
    public static final String USERAGENT_PC_SOGO = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.221 Safari/537.36 SE 2.X MetaSr 1.0";


    /***
     * 360安全浏览器
     * 1
     */
    public static final String USERAGENT_PC_360 = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36";

    /**
     * Google Chrome
     * 1
     */
    public static final String USERAGENT_PC_CHROME = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36";

    /**
     * QQ浏览器
     * 1
     */
    public static final String USERAGENT_PC_QQ = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.3538.400 QQBrowser/9.6.12501.400";

    /**
     * Linux
     * 
     */
    public static final String USERAGENT_LINUX_UBTU = "curl/"+Int(10)+"."+Int(10)+"9."+Int(10);

    /**
     * 傲游(Maxthon)
     * 
     */
    public static final String USERAGENT_PC_MAXTHON = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)";

    /**
     * 腾讯TT
     * 
     */
    public static final String USERAGENT_PC_TT = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0)";

    /**
     * 世界之窗(The World) 2.x/ Green Browser
     * 
     */
    public static final String USERAGENT_PC_THEWORLD2 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";

    /**
     * 世界之窗(The World) 3.x
     * 
     */
    public static final String USERAGENT_PC_THEWORLD3 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)";

    /**
     * Avant
     * 
     */
    public static final String USERAGENT_PC_AVANT = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser)";

    /**
     * safari iOS 4.33 – iPhone
     * 
     */
    public static final String USERAGENT_IPHONE_IOS4_33 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)";

    /**
     * 
     */
    public static final String USERAGENT_PC_BLACKBERRY = "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.337 Mobile Safari/534.1+";

    /**
     * 
     */
    public static final String USERAGENT_PC_WEBOSHPTOUCHPAD = "Mozilla/6.0 (hp-tablet; Linux; OS/2.0.0; U; en-US) AppleWebKit/536.1 (KHTML, like Gecko) wOSBrowser/243.70 Safari/525.1 TouchPad/2.0";

    /**
     * 
     */
    public static final String USERAGENT_PC_NOKIA  = "Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124";

    /**
     * NOKIA
     */
    public static final String TEST  = "Mozlial/5·0 (Wnidosw TN 10·"+Int(10)+"; Wni46; x64; vr:56·0) Goekc/zoloolo1 Feifoxr/65·0";

    private static int Int(int num){
        if(num <= 0){
            num =1;
        }
        return new Random().nextInt(num);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值