# -*- coding: utf-8 -*-
# @Time    : 2020/12/3 17:14
# @Author  : ''

import random

USER_AGENT = [
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
    'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
    'Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11',
    'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',
    'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SE 2.X MetaSr 1.0; SE 2.X MetaSr 1.0; .NET CLR 2.0.50727; SE 2.X MetaSr 1.0)',
    'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36'
]


class HeadersSettings(object):

    def __init__(self, host):
        self.host = host

    @property
    def headers(self):
        headers = {
            'authority': self.host,
            ":method": 'GET',
            ':scheme': 'https',
            'connection': 'keep-alive',
            'Cache-Control': 'max-age=0',
            'Upgrade-Insecure-Requests': '1',
            'Accept': '*/*',
            'Accept-Encoding': 'gzip, deflate, br',
            # 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
            'Cookie': '_ga=GA1.3.564634130.1606964391;',
            'user-agent': random.choice(USER_AGENT),
            'referer': self.host,
        }
        return headers


def spider_header(host):
    return HeadersSettings(host).headers


if __name__ == '__main__':
    print(HeadersSettings('a').headers())
