Giter Site home page Giter Site logo

Comments (2)

ljluestc avatar ljluestc commented on July 16, 2024 1
  1. Modify CurrencyRates in the forex_python.converter module:
import requests
from forex_python.converter import CurrencyRates as BaseCurrencyRates

class CurrencyRates(BaseCurrencyRates):
    def __init__(self, session=None, proxies=None, verify_ssl=True):
        super().__init__()
        if session is None:
            session = requests.Session()
        if proxies is not None:
            session.proxies = proxies
        session.verify = verify_ssl
        self.session = session

    # ... rest of the class methods ...

# This import ensures that the class is available when the module is imported
CurrencyRates()
  1. Usage:
from forex_python.converter import CurrencyRates

# Create a session with proxy settings and SSL verification turned off
proxies = {
    'http': 'http://proxy.example.com:8080',
    'https': 'https://proxy.example.com:8080'
}
currency_rates = CurrencyRates(proxies=proxies, verify_ssl=False)

# Now you can use the `currency_rates` object for your API calls

Keep in mind that this approach involves modifying the library's code directly. If you choose to go this route, make sure to take care and consider the impact on future library updates.

Alternatively, if modifying the library directly isn't desired, you could create a wrapper class that inherits from CurrencyRates and adds the desired functionality. This would allow you to achieve the desired behavior without modifying the original library code.

from forex-python.

amarvin avatar amarvin commented on July 16, 2024
  1. Modify CurrencyRates in the forex_python.converter module:
import requests
from forex_python.converter import CurrencyRates as BaseCurrencyRates

class CurrencyRates(BaseCurrencyRates):
    def __init__(self, session=None, proxies=None, verify_ssl=True):
        super().__init__()
        if session is None:
            session = requests.Session()
        if proxies is not None:
            session.proxies = proxies
        session.verify = verify_ssl
        self.session = session

    # ... rest of the class methods ...

# This import ensures that the class is available when the module is imported
CurrencyRates()
  1. Usage:
from forex_python.converter import CurrencyRates

# Create a session with proxy settings and SSL verification turned off
proxies = {
    'http': 'http://proxy.example.com:8080',
    'https': 'https://proxy.example.com:8080'
}
currency_rates = CurrencyRates(proxies=proxies, verify_ssl=False)

# Now you can use the `currency_rates` object for your API calls

Keep in mind that this approach involves modifying the library's code directly. If you choose to go this route, make sure to take care and consider the impact on future library updates.

Alternatively, if modifying the library directly isn't desired, you could create a wrapper class that inherits from CurrencyRates and adds the desired functionality. This would allow you to achieve the desired behavior without modifying the original library code.

Great workaround, thanks!

from forex-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.