Parameters in the webclient

I want to put parameters in the webclient link.
It’s usually the Python language at the bottom.
I want to put the text keyword in the link.
https://news.google.com/rss/search?q={encoded_params}

I’d like to put encoded_params = text.

Attached is the file. What should I do?


test link.1.toe (5.3 KB)

///////

import urllib.parse

params = {
    "q": "car",
    "hl": "en",  
}

encoded_params = urllib.parse.urlencode(params)
url = f"https://www.google.com/search?q={encoded_params}"

print(url)

Hi!

Given the following network:

With the text DAT text2 containing the script:

import urllib.parse

params = {
    "q": "car",
    "hl": "en",  
}

encoded_params = urllib.parse.urlencode(params)
url = f"https://www.google.com/search?q={encoded_params}"

print(url)

op('webclient2').request(url, 'GET')

You should be able to make the request.

I believe when a URL ends with a “?” and parameters, that makes it a GET request. So setting the web client DAT like this also works:
image

Hope this helps!

You can simply use the pars keyword in the webclientDAT.request method. The value should be a dictionary filled with the non-url encoded parameter values. In your case that would be something like:

params = {
    "q": "car",
    "hl": "en",  
}

op('webclient').request('https://www.google.com/search', 'GET', pars=params)

I tried, but when I request, the frame is lowered, and the screen stops.
It doesn’t work, what should I do?
And what do I do if I want to put a car from Dat, not a car in the parameter?
Attached is the file.

test link.9.toe (6.3 KB)

Hi @kijhome,

your script with the .request() call to the webClient DAT should not be in the webclient’s callbacks DAT but in a seperate script. The callbacks DAT is executed everytime the Web Client DAT connects, disconnects, or receives a response. So you are ending up in a endless loop of requesting a url, connecting, requesting, connecting, requesting…

You would either use a Text DAT to run the script as shown above by @JoshKery but using @eric.b pars argument in the .request method, or use a Table DAT with your arguments as the second input to the Web Client DAT.

Attached file has samples for both techniques.

I’m using the url news.google.com/rss/search as in your original question.

cheers
Markus
base_webClientExamples.tox (10.1 KB)