Python爬虫:fake_useragent库模拟浏览器请求头

作者阿里云代理 文章分类 分类:linux图文教程 阅读次数 已被围观 685

简单示例

# -*- coding: utf-8 -*-  # @File    : fake_useragent_demo.py # @Date    : 2018-05-28  from fake_useragent import UserAgent  ua = UserAgent()  print(ua.ie)  print(ua.opera)  print(ua.chrome)  print(ua.google)  print(ua.firefox)  print(ua.safari)  print(ua.random)  """ Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.0; Trident/4.0; InfoPath.1; SV1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 3.0.04506.30) Opera/9.80 (Windows NT 6.0; U; en) Presto/2.7.39 Version/11.00 Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36 Mozilla/5.0 (X11; CrOS i686 3912.101.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0 Mozilla/5.0 (Windows; U; Windows NT 6.1; sv-SE) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0) Opera 12.14 """
本公司销售:阿里云、腾讯云、百度云、天翼云、金山大米云、金山企业云盘!可签订合同,开具发票。

我有话说: