当前位置:网站首页>[API packet capturing in selenium automation] installation and configuration of browsermobproxy
[API packet capturing in selenium automation] installation and configuration of browsermobproxy
2022-06-28 23:11:00 【Review of the white speed Dragon King】
First step
pip install browsermob-proxy
Load a bag first
The second step
requirement jdk1.8 The above environment variables depend on
ps: If it is a newly equipped environment, remember , Restart it 
The third step
download java End BrowserMob-Proxy package :http://bmp.lightbody.net/
Take it directly ( stay py Remember to write... When configuring browsermob-proxy.bat Address )
experiment : use Baidu Search

for instance , I want to catch any one js Of response have a look

You can really see some rough information , Meticulous js The code needs to be explored
Complete code
from browsermobproxy import Server
from selenium import webdriver
import time
import pprint
class ProxyManger:
__BMP = r"C:\Users\Irving\Desktop\echain\browsermob-proxy-2.1.4-bin\browsermob-proxy-2.1.4\bin\browsermob-proxy.bat"
def __init__(self):
self.__server = Server(ProxyManger.__BMP)
self.__client = None
def start_server(self):
self.__server.start()
return self.__server
def start_client(self):
self.__client = self.__server.create_proxy(params={
"trustAllServers": "true"})
return self.__client
@property
def client(self):
return self.__client
@property
def server(self):
return self.__server
if __name__=="__main__":
# Turn on Proxy
proxy = ProxyManger()
server = proxy.start_server()
client = proxy.start_client()
# To configure Proxy start-up WebDriver
options = webdriver.ChromeOptions()
options.add_argument("--proxy-server={}".format(client.proxy))
options.add_argument('--ignore-certificate-errors')
options.add_argument('--headless')
#chromePath = r"D:\AzRjN\anaconda3_7\envs\demo36\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe"
driver = webdriver.Chrome(chrome_options=options)
# Get the returned content
client.new_har("baidu.com", options={
'captureHeaders': True, 'captureContent': True})
driver.get("https://www.baidu.com/")
time.sleep(3)
result = client.har
print(result)
for entry in result['log']['entries']:
_url = entry['request']['url']
print(" Request address :", _url)
if "https://pss.bdstatic.com/r/www/cache/static/protocol/https/amd_modules/san/dist/san_5017f11.js" in _url:
_response = entry['response']
_content = _response['content']
print("---------https://pss.bdstatic.com/r/www/cache/static/protocol/https/amd_modules/san/dist/san_5017f11.js Request response content :", _response)
server.stop()
summary
selenium While automating the operation
browsermobproxy Grab a bag on one side
边栏推荐
- 在线SQL转HTMLTable工具
- [chapter 71 of the flutter problem series] mutual conversion between uint8list and image in flutter
- 在DialogFragment的onStop(完全不可见)时调用dismiss退出界面报错解决办法
- 【Flutter 问题系列第 71 篇】Flutter 中 Uint8List 和 Image 之间的相互转换
- 复杂嵌套的对象池(4)——管理多类实例和多阶段实例的对象池
- LeCun预言AGI:大模型和强化学习都是斜道!我的世界模型才是新路
- 【深度学习】(2) Transformer 网络解析,代码复现,附Pytorch完整代码
- CIN at QT (the clearest tutorial in the whole network)
- Chapter V virtual memory exercise
- LeetCode 324 摆动排序 II[排序 双指针] HERODING的LeetCode之路
猜你喜欢

One card can sell tens of millions, and the business expansion is faster than that of players: you don't understand the Jianghu of star cards

WMS仓库管理系统模块之波次拣货

Online sql to htmltable tool

LeCun预言AGI:大模型和强化学习都是斜道!我的世界模型才是新路

2022 PMP project management examination agile knowledge points (4)

带链接跳转的微信红包封面制作教程和使用指南

Fanuc robot_ Introduction to Karel programming (2)_ Usage of general IO signal

【深度学习】(2) Transformer 网络解析,代码复现,附Pytorch完整代码

See fengzhixia | FENGZikai, the originator of Guoman, for exclusive sale of Digital Collections

How to use London gold to draw support resistance line
随机推荐
Small sample sharp weapon 2 Text confrontation + semi supervised FGSM & VAT & FGM code implementation
收藏 | VLOOKUP函数的这些妙用你都知道吗?
自媒体行业内卷严重:企业自媒体应该何去何从
[word Tutorial Series Part 1] how to remove arrows in word tables
DBNN实验进展
CIN at QT (the clearest tutorial in the whole network)
Google Earth engine (GEE) -- crop extraction and analysis using sentinel-2 data
Undefined symbol main (referred from entry9a.o).
第二章 经典同步练习作业
Business atlas in super factory
[flutter issues Series title 71] Mutual Conversion between uint8list and Image in flutter
Undefined symbol main (referred from entry9a.o).
WMS仓库管理系统模块之波次拣货
第五章 虚拟存储器 练习
在QT进行cin(全网最清晰教程)
Non scientific class! The road of self-study!
长投学堂帮忙开证券账户是安全靠谱的吗?个人如何开
How to use London gold to draw support resistance line
[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached
小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现