当前位置:网站首页>Crawl IP
Crawl IP
2022-07-28 19:57:00 【Mountains and rivers don't grow old】
1. User agent tools
1).fake-useragent install
pip install fake-useragent
2). Usage method
from fake_useragent import UserAgent # Import package
ua = UserAgent() # Instantiation
ua.ie # Random generation IE Browser's UserAgent
ua.firefox # Random generation firefox Browser's UserAgent
ua.chrome # Random generation chrome Browser's UserAgent
ua.safari # Random generation safari Browser's UserAgent
ua.google # Random generation google Browser's UserAgent
ua.random # Random generation of various browsers UserAgent
3). Example of camouflage head
from fake_useragent import UserAgent
ua = UserAgent()
headers = {
'User-Agent':ua.random}
4).
If you do not want to cache the database or do not need a writable file system .
ua = UserAgent(cache=False)
5).
If you don't want to use a hosted cache server , You can disable the server cache
ua = UserAgent(use_cache_server=False)
6).
If the above methods report errors , perform
ua = UserAgent(verify_ssl=False)
because fake-useragent Library maintenance user-agent The list is stored on the online web page
List pages that are too low version dependent may report 403
7). to update
ua.update()
8). Check all user-agent
ua.data_browsers
In [20]: len(reduce(lambda a, b: a+b, ua.data_browsers.values()))
Out[20]: 250
# Get random values
In [26]: ua.random
Out[26]: 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/31.0.1650.16 Safari/537.36'
9). see useragent The contents of the library
You can visit the website :
https://fake-useragent.herokuapp.com/browsers/ Version number
Reference website
python Reptiles —— Build agents ip pool
python Crawler settings proxy ip pool —— Method ( One )
Python Reptiles ——requests ip agent
边栏推荐
- My second blog - C language
- MySQL8 基于clone创建主从复制
- Common modules of saltstack
- Cell review: single cell methods in human microbiome research
- 并发程序设计,你真的懂吗?
- How openocd directly downloads programs to STM32 board through stlink (solved)
- Information management system and games based on C language
- Use Hal Library of STM32 to drive 1.54 inch TFT screen (240*240 st7789v)
- MIR专题征稿 | 常识知识与推理:表示、获取与应用 (10月31日截稿)
- In the second half of 2022, the system integration project management engineer certification starts on August 20
猜你喜欢

河北:稳粮扩豆助力粮油生产提质增效

【NPP安装插件】

How does app automated testing achieve H5 testing

软考中级(系统集成项目管理工程师)高频考点

Business visualization - let your flowchart "run" (4. Actual business scenario test)

Android-第十三节03xUtils-数据库框架(增删改查)详解

基于C语言的信息管理系统和小游戏

Basic usage of docker

Saltstack configuration management

This customized keyboard turns me on~
随机推荐
MySQL8 Status Variables: Internal Temporary Tables and Files
软考高级考试中有五大证书,哪个更值得考?
基于QTGUI图像界面的空战游戏设计
并发程序设计,你真的懂吗?
Kubeedge releases white paper on cloud native edge computing threat model and security protection technology
Thoroughly understand bit operations -- and (&), not (~), or (|), XOR (^)
Redis notes
shared_ PTR and make_ Use of shared
How to write the SQL statement of time to date?
Know small and medium LAN WLAN
Leetcode Day2 consecutive numbers
克服“看牙恐惧”,我们用技术改变行业
Leetcode Day1 score ranking
How does app automated testing achieve H5 testing
KPMG China: insights into information technology audit projects of securities fund management institutions
美国将提供250亿美元补贴,鼓励英特尔等芯片制造商迁回产线
JS preventdefault() keyboard input limit onmousewheel stoppropagation stop event propagation
Data system of saltstack
Nokia expands its 5g agreement with BT and will become its largest wireless access device supplier
Getting started with enterprise distributed crawler framework