Utilizing Python SDK to access Watson Discovery API via an HTTP Proxy server

Utilizing the Watson Python SDK from https://github.com/watson-developer-cloud/python-sdk, I am attempting to send a search request to the Watson Discovery service. However, due to being behind an HTTP proxy, I am unable to reach the Watson Discovery service.

Can you please provide guidance on how to modify this python script (watson-developer-cloud/python-sdk) to be executed in an HTTP proxy environment?

from watson_developer_cloud import DiscoveryV1

discovery = DiscoveryV1(
  username=username,
  password=password,
  version="2017-11-07"
)

collection = discovery.get_collection(environment_id, collection_id)

Answer №1

Utilize the set_http_config() method available

http_configuration = {
    "proxies": {
        "https": "URL",
        "http": "URL"
    }
}
service.set_http_config(http_configuration)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Python with vobject library to encode and manipulate vCards efficiently

Currently, I am utilizing the vobject library in Python to parse a specific vcard. The URL for this vCard can be found here: My code for parsing the vCard is as follows: import urllib import vobject vcard = urllib.urlopen("http://www.mayerbr ...

What is the purpose of using numpy.ravel() in this code snippet that generates small multiples?

I recently came across some code that creates a set of small multiples and it is functioning flawlessly. fig, axes = plt.subplots(6,3, figsize=(21,21)) fig.subplots_adjust(hspace=.3, wspace=.175) for ax, data in zip(axes.ravel(), clean_sets): ax.plot(d ...

What methods are available for efficiently storing chunks of dictionary objects in Python?

Working with Python and the pickle module, my goal is to store multiple large dictionaries with similar structures in separate files. I then need to create a lookup that iterates through the keys one by one and processes the data contained in all dictionar ...

Enhancing Django's UserCreationForm

How can I modify Django's django.contrib.auth.forms.UserCreationForm to add email and name fields? My UserChangeForm extension is successful, but for some reason, UserCreationForm still only shows the default username, password1, and password2 fields. ...

Executing JavaScript with Python in Selenium

Completely new to Selenium. I need help running a javascript snippet in this code (as commented), but struggling to do so. from selenium import webdriver import selenium from selenium.common.exceptions import NoSuchElementException from selenium.webdriver ...

Analyzing two sets of data to identify unique pairings

I am currently working on comparing two lists that have varying sublists sizes, and I need to find pairs (enclosed in round brackets) that are present in one list but not the other. Check out the code snippet below: s1 = [ [('RESOLVED - DUPLICAT ...

Gradually Enhancing the Functionality of Pandas Groupby Transform Operation

I am facing an issue with a massive DataFrame containing multiple columns that are GroupBy functions of the original data. The process of computing these functions is extremely time-consuming. Currently, every day I receive new data and have to recompute a ...

Is there a way to automate opening a new window while closing the current one using Python and Selenium?

I have a collection of website links (URLs) that I want to open in separate tabs. For example: youtube.com google.com facebook.com The process should first open YouTube, then Google in a new tab. After closing the YouTube tab, the script should proceed t ...

Assorted arrays of void arrays

For my Python program, I need to create two empty lists and populate them with randomly selected numbers based on a given range and number of selections. Here's how the program should work: Select from Range: 15 Number of Selections: 7 The desired ...

Plotting the Plank radiation equation on a log scale with a restricted range

I'm currently working on plotting the Planck radiation equation. Strangely enough, my attempts in Mathematica have been successful, but I've hit a roadblock when trying to recreate the plot in Python. For some reason, it won't display data f ...

What is the best way to upload a JSON file onto a local server?

After struggling for the past two hours trying to solve a problem I encountered, I've come to realize that accessing a local JSON file named data.json from my project directory is not possible due to cross-origin requests limitations. In order to acce ...

Scraping data from a webpage using Python: A step-by-step guide

On 29/01/2010, I attempted to extract data from the website: However, I encountered difficulty in retrieving the table data due to the lack of an identifiable ID associated with that date. Can anyone provide assistance in this matter? Here is what I trie ...

Python Creating a callback function in Matplotlib with parameters

Is it possible to pass additional parameters other than 'event' in a callback function for button presses? For example, I need to access the text of the button ('Next' in this scenario) within the callback function. How can this be achi ...

Looking to learn how to divide data into two distinct lines on a single graph?

https://i.stack.imgur.com/fl7iq.png The data I am working with has a similar format to the image above. After successfully creating a graph that represents the total sum of suicides per 100k population over the years using the code below: df2 = df2[df2. ...

Removing numerous elements in JSON structures

name_list = [{'name': 'John'}, {'name': 'Johan'}, {'name': 'John'}] for i in xrange(len(name_list)): if name_list[i]["name"] == "John": del name_list[i] Once the code rec ...

Arranging JSON data in Python based on string values for sorting

I have a JSON file containing employee information: ll = {"employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"James", "lastName":"Bond"}, {"firstName":"Celestial", "lastName":"Syste ...

Dynamic retrieval of field types based on a field from a separate class (Leveraging Scapy tool in Python)

Is there a way to dynamically define field types for a class based on a field from another class? I am trying to link a field from one class to another class, for example: class TemplateRecord(Packet): name = "Template Record" fields_desc = [ Sh ...

The headless mode of Python Selenium with Chrome driver is not functioning properly

I attempted to create a bot that automates purchases on Amazon's website, and I succeeded. However, when I tried to optimize the bot for speed by making the Chrome driver headless, it stopped functioning properly (specifically, it kept going to a NoS ...

Tips for modifying pixel values in Python's OpenCV library without the need for traditional for loops

Currently delving into OpenCV in Python and I've encountered an issue. I have a depth image captured from a Kinect camera. This image has a border with pixel values of zero that I need to replace with the maximum value in the image (2880) without res ...

"What is the most effective way to traverse through a complex dictionary structure

Hey there! I couldn't find a specific answer to my question on stack overflow, so I'm reaching out for your help. I have a nested dictionary that I want to iterate through in order to create a specific string. Can you guide me through this proces ...