Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaliiiiiiiiii/selenium-interceptor
Intercept request using Selenium with Chrome
https://github.com/kaliiiiiiiiii/selenium-interceptor
automation cdp chrome chrome-developer-protocol proxy python selenium webdriver
Last synced: 6 days ago
JSON representation
Intercept request using Selenium with Chrome
- Host: GitHub
- URL: https://github.com/kaliiiiiiiiii/selenium-interceptor
- Owner: kaliiiiiiiiii
- License: other
- Created: 2023-01-11T10:55:10.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-23T08:49:18.000Z (10 months ago)
- Last Synced: 2024-11-02T13:21:23.597Z (13 days ago)
- Topics: automation, cdp, chrome, chrome-developer-protocol, proxy, python, selenium, webdriver
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 18
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Selenium-Interceptor
* Modifying or [adding headers](#Change-headers)
* Modify response### Feel free to test my code!
## Getting Started
### Dependencies
* [Python >= 3.7](https://www.python.org/downloads/)
* [Chrome-Browser](https://www.google.de/chrome/) installed
* Selenium### Installing
* [Windows] Install [Chrome-Browser](https://www.google.de/chrome/)
* ```pip install selenium-interceptor```### Change-headers
```pythonfrom selenium_interceptor.interceptor import cdp_listener
from selenium_profiles import driver as mydriver
from selenium_profiles.profiles import profilesmydriver = mydriver()
profile = profiles.Windows()driver = mydriver.start(profile)
cdp_listener = cdp_listener(driver=driver)
cdp_listener.specify_headers({"sec-ch-ua-platform":"Android"})
thread = cdp_listener.start_threaded(listener={"listener": cdp_listener.requests, "at_event": cdp_listener.modify_headers})driver.get("https://modheader.com/headers?product=ModHeader")
```
Don't forget to execute
`cdp_listener.terminate_all()`
in the End. Else-wise your temporary folder will get flooded! (Windows) and it keeps running## Help
Please feel free to open an issue or fork!
## Todo
## Deprecated
## Authors
[Aurin Aegerter](mailto:[email protected])
## License
Shield: [![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa]
This work is licensed under a
[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].[![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa]
[cc-by-nc-sa]: http://creativecommons.org/licenses/by-nc-sa/4.0/
[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png
[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg## Disclaimer
I am not responsible what you use the code for!!! Also no warranty!
## Acknowledgments
Inspiration, code snippets, etc.
* [Selenium-Profiles](https://github.com/kaliiiiiiiiii/Selenium-Profiles)
* [Chrome-devtools-protocol](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-enable)
* [cdp_event_listeners](https://stackoverflow.com/questions/66227508/selenium-4-0-0-beta-1-how-add-event-listeners-in-cdp)