Git Product home page Git Product logo

fakeuseragent's Introduction

Fake UserAgent

Build Status GoDoc Go Report Card codecov

0. Install

go get github.com/wuxiaoxiaoshen/fakeuseragent/application

1. Features

从下面几个网站中抓取到 User-Agent 数据。

2. User-Agent 的知识

  • User-Agent 用户代理
  • 是一个特殊的字符串
  • 作用是服务器识别客户使用的操作系统及版本、CPU 类型、浏览器及版本、浏览器渲染引擎、浏览器语言、浏览器插件等

User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36

3. Usage

package main

import (
	"fmt"

	"github.com/wuxiaoxiaoshen/fakeuseragent/application"
)

func main() {
	fakeUserAgent := application.NewFakeUserAgent(false)
	fmt.Println(fakeUserAgent.Random())
	fmt.Println(fakeUserAgent.Safari())
	fmt.Println(fakeUserAgent.Chrome())
	fmt.Println(fakeUserAgent.IE())
	fmt.Println(fakeUserAgent.Opera())
}

结果:

Mozilla/4.0 (compatible; MSIE 6.0; Windows ME) Opera 7.53  [en]
Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.20
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.1 (KHTML, like Gecko) Chrome/4.0.220.1 Safari/532.1
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko
Opera/9.64 (X11; Linux x86_64; U; en-GB) Presto/2.1.1

3.1 方法

  • Random 随机得到一个 UserAgent
  • IE/Msie/InternetExplorer 返回IE 浏览器UserAgent
  • FF/FireFox 返回 FireFox 浏览器UserAgent
  • Google/Chrome 返回 Chrome 浏览器UserAgent
  • Opera 返回 Opera 浏览器UserAgent

3.3 参数

参考:Python 版 fake-useragent

License

MIT ©wuxiaoxiaoshen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.