[PYTHON] Proxy measures when using WEB API

The Python Requests module uses an environment variable proxy. So let's set it as an environment variable.

By calling the following function at the beginning of main, you will be able to exit the proxy with requests.

import os

# Proxy setting
def proxy_setting():
    proxy_user = 'proxy_user'
    proxy_pass = 'proxy_pass'
    proxy_url = '******:8080'
    os.environ["http_proxy"] = 'http://' + proxy_user + ':' + proxy_pass + '@' + proxy_url
    os.environ["https_proxy"] = 'http://' + proxy_user + ':' + proxy_pass + '@' + proxy_url

Recommended Posts

Proxy measures when using WEB API
Use configparser when using API
Procedure to use TeamGant's WEB API (using python)
Hit the Web API using requests Example: Flickr
Settings when using Jupyter Notebook under Proxy server
Proxy settings when using pip or Jupyter Notebook
Load test method when using external service API
Summary when using Fabric
Initial settings when using the foursquare API in python
Learning neural networks using Chainer-Creating a Web API server
Web application using Bottle (1)
Precautions when using Chainer
Build a web API server at explosive speed using hug
A story that stumbled when using pip in a proxy environment
View the contents of the queue using the RabbitMQ Management Web API
Image Optimize on the server side using TinyPNG's Web API
(Personal) points when using ctypes
Environment variables when using Tkinter
When using optparse with iPython
WEB application development using django-Development 1-
Test CloudStack API Using Simulator
EXE Web API by Python
Age recognition using Pepper's API
Try using the Twitter API
Upload videos using YouTube API
DEBUG settings when using Django
Web API with Python + Falcon
Try using the Twitter API
Web scraping using Selenium (Python)
Try using the PeeringDB 2.0 API
When using if and when using while
File structure when using serverless-python-requirements
Web scraping using AWS lambda
Small speedup when using pytorch
About HTTP cache when developing REST API-based web application [using GCP]
[Web development with Python] Measures against garbled characters when outputting html
[SEO] Flow / sample code when using Google Analytics API in Python