2025年3月31日 星期一 乙巳(蛇)年 正月初一 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > Python

python随机获取请求头

时间:08-25来源:作者:点击数:35
城东书院 www.cdsy.xyz

python随机获取请求头

安装包

  • pip install fake_useragent
  • pip install faker

用法

  • # -*- coding:utf-8 -*-
  • # #可以随机获取一个user-agent头
  • from fake_useragent import UserAgent #pip install fake_useragent
  • ua = UserAgent()
  • user_agent=ua.random
  • print(user_agent)
  • # #使用Faker库随机生成虚假header
  • from faker import Faker #pip install faker
  • fake = Faker()
  • headers ={'User-Agent':fake.user_agent()}
  • print(headers)
城东书院 www.cdsy.xyz
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐