Proxyman
HomepageDownload
  • Overview
  • Changelog
  • License
  • License Manager
  • Raycast
  • Command-line
  • Security Compliance
  • Proxyman iOS
    • Proxyman for iOS
    • Map Local for iOS
    • Breakpoint for iOS
    • Tutorial for iOS
      • Map Local for iOS Tutorial
      • Breakpoint for iOS Tutorial
  • Debug on Devices
    • macOS
    • iOS Device
    • iOS Simulator
    • tvOS & watchOS
    • Android Device & Emulator
      • Automatic Script for Android Emulator
      • Sample Android Project
    • Firefox
    • Java VMs
    • Python
    • Ruby
    • NodeJS
    • Rust
    • Golang
    • React Native
    • Flutter
    • HTTP Clients
    • Docker
    • ElectronJS
    • NextJS (fetch)
  • Automatic Setup
    • Automatic Setup
    • Manual Setup
    • Troubleshooting
  • Atlantis
    • Atlantis for iOS
  • BASIC FEATURES
    • Proxyman Proxy Helper Tool
    • Request / Response Previewer
    • SSL Proxying
    • Bypass Proxy List
    • Import / Export
    • Content Filter
    • Multiple Tabs
    • Horizontal/Vertical/Window Layout
    • Copy as
    • Custom Previewer Tab
    • Custom Header Column
    • Regex (Regular Expression)
    • Filter JSON Response
    • Highlight by Color and Add Comment
    • Import / Export Settings
    • Multipart Form-Data Previewer
    • JSONPath
    • Customize Toolbar
    • Localization
    • Quick Preview
  • ADVANCED FEATURES
    • Repeat
    • Edit & Repeat
    • Compose new Request
    • No Caching
    • Breakpoint
    • Breakpoint Templates
    • Map Local (File)
    • Map Local (Directory)
    • Map Remote
    • External Proxy
    • Save Session
    • Protobuf
    • WebSocket
    • Clear Session
    • Block List
    • Allow List
    • Charles Proxy Converter
    • Custom Certificates
    • GraphQL
    • Network Conditions
    • Multiple Filters
    • Custom Filters
    • Publish to Gist
    • Reverse Proxy
    • Code Generator
    • Diff
    • Access Control
    • DNS Spoofing
    • SOCKS Proxy
    • Swagger OpenAPI
    • TLS Key Logging
  • Proxyman Windows
    • Install Certificate
    • WSL
  • Scripting
    • Scripting
    • async/await Request
    • Addons
    • Built-in JS Libraries
    • Write your own Addons
    • Snippet Code
    • Environment Variables
  • Troubleshooting
    • Proxyman does not work with VPN apps
    • My Remote Devices (iOS/Android) could not connect to Proxyman?
    • iOS 16 and iOS 17 issues
    • SSL Error from HTTPS Request/Response
    • I could not see any requests from my localhost server
    • I could not see any HTTP traffic from my NodeJS, Python, or Ruby scripts
    • *.local requests do not appear on Proxyman
    • I couldn't see any traffics on Proxyman
    • I couldn't see any requests from 3rd-party network libraries
    • [Breakpoint] Modify Request/Response by Raw Message
    • Could not change Proxyman App Icons
    • Lost data after updating Proxyman app?
    • Proxyman consumes too much RAM & unresponsive
Powered by GitBook
On this page
  • 1. New Automatic Solution (v4.7.0 or later) ✅
  • How to use:
  • 2. Old Solution (Not recommended) ❌
  • 1. Script Approach
  • 2. Manual Approach
  • - Install Proxyman on the Python environment
  • - Revert the change
  • 3. Troubleshooting
  • Reference
  1. Debug on Devices

Python

Capture HTTP/HTTPS traffic from Python with Proxyman

PreviousJava VMsNextRuby

Last updated 2 years ago

1. New Automatic Solution (v4.7.0 or later) ✅

Proxyman v4.7.0 or later can capture HTTP/HTTPS traffic from Python with 1-click.

  • 1-click solution: No need to manually set HTTP Proxy config or trust the self-signed certificate.

  • Support many Python libraries: request, http.client, urllib3, httpx and aiohttp

How to use:

  1. Open Proxyman -> Setup Menu -> Automatic Setup

  2. Click on "Open New Terminal"

  3. Accept the Apple Script permission prompt if needed

  4. The New Terminal app is launched -> You can start your Python Backend Server, or Run scripts => Proxyman automatically captures all traffic.

  5. Done ✅

Please check out the Automatic Setup page:

2. Old Solution (Not recommended) ❌

1. Script Approach

  1. Save the script to ~/desktop file with the name is script.py

  • Add Certificate:

$ python3 script.py add
  • Remove Certificate

$ python3 script.py remove

For macOS 12.2 or later, make sure you use python3

2. Manual Approach

- Install Proxyman on the Python environment

By default, Python on macOS doesn't trust Proxyman self-signed certificates. As a result, you might encounter SSL Error if you try to intercept HTTPS traffic.

If you would like to intercept HTTPS Traffic from your Python script, you have to explicitly tell Python to use the Proxyman Root Certificate at ~/.proxyman/proxyman-ca.pem

Please follow the guideline:

  1. Run the following CLI on your Terminal app

$ export SSL_CERT_FILE=~/.proxyman/proxyman-ca.pem
$ export REQUESTS_CA_BUNDLE=~/.proxyman/proxyman-ca.pem
$ echo "export REQUESTS_CA_BUNDLE=~/.proxyman/proxyman-ca.pem" >> ~/.bash_profile ; source ~/.bash_profile

3. Done.

- Revert the change

If you don't use Proxyman, please revert the change by commenting out:

# export REQUESTS_CA_BUNDLE=~/.proxyman/proxyman-ca.pem

in ~/.bash_profile

3. Troubleshooting

3.1 Proxyman could not capture HTTP traffic from my Python code.

Reference

Use to automatically install/remove the certificate to Python.

Credit to

Install Proxyman Certificate on Mac (If you've done it, please skip it. If not, please check out ).

Solution: Please use the .

Automatic Setup
the following script
@novitae
Automatic Setup
https://github.com/ProxymanApp/Proxyman/issues/948#issuecomment-890520435
https://github.com/ProxymanApp/Proxyman/issues/1220
MacOS Guideline
Capture NodeJS Traffic with Proxyman