The data parameter of urlopen is used to set the body of the request. GET requests cannot contain a body, as they should only be used to return a resource, which should only be defined by it's URL.

If you need to pass parameters, you can append them to the url, in your case :

from urllib.request import urlopen
urlopen('http://localhost:8082/v3/nodes?{}'.format(query))
Answer from ploutch on Stack Overflow
🌐
Python
docs.python.org › 3 › library › urllib.request.html
urllib.request — Extensible library for opening URLs — Python ...
Otherwise, if resolve_host is set to true, the authority is resolved using socket.gethostbyname() and discarded if it matches a local IP address (as per RFC 8089 §3). If the authority is still unhandled, then on Windows a UNC path is returned, and on other platforms a URLError is raised. This example shows the function being used on Windows: >>> from urllib.request import url2pathname >>> url = 'file:///C:/Program Files' >>> url2pathname(url, require_scheme=True) 'C:\\Program Files'
🌐
Real Python
realpython.com › urllib-request
Python's urllib.request for HTTP Requests – Real Python
January 11, 2025 - If you’re looking to make HTTP requests in Python using the built-in urllib.request module, then this tutorial is for you. urllib.request lets you perform HTTP operations without having to add external dependencies.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-urllib-module
Python Urllib Module - GeeksforGeeks
July 12, 2025 - Urllib package is the URL handling module for python. It is used to fetch URLs (Uniform Resource Locators).
🌐
Python Module of the Week
pymotw.com › 3 › urllib.request › index.html
urllib.request — Network Resource Access
December 18, 2016 - When creating an application that will access web resources owned by someone else, it is courteous to include real user agent information in the requests, so they can identify the source of the hits more easily. Using a custom agent also allows them to control crawlers using a robots.txt file (see the http.robotparser module). ... from urllib import request r = request.Request('http://localhost:8080/') r.add_header( 'User-agent', 'PyMOTW (https://pymotw.com/)', ) response = request.urlopen(r) data = response.read().decode('utf-8') print(data)
🌐
Simplilearn
simplilearn.com › home › resources › software development › python internet access using urllib.request and urlopen()
Python Internet Access Using Urllib.Request and Urlopen() | Simplilearn
October 9, 2024 - This article explains the Urllib python, urllib request urlopen() functions present in Python, which help in accessing the Internet using Python. Explore now.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Find elsewhere
🌐
Real Python
realpython.com › videos › basic-urllib-request
Perform Basic HTTP Requests With urllib.request (Video) – Real Python
You’ll also make a GET request to a mock REST API, such as {JSON} Placeholder, for some JSON data. 00:22 First, make sure you’re using Python 3 or above. Then head over to your favorite code editor and open up a new file. 00:29 Here I am in my code editor, VS Code, and I just created a file named HTTPResponse.py. First, you’ll import urlopen from urllib.request.
Published   January 2, 2024
🌐
Medium
aignishant.medium.com › working-with-pythons-urllib-library-a-beginner-s-guide-79bcad776a8e
Working with Python’s urllib Library: A Beginner’s Guide | by Nishant Gupta | Medium
March 26, 2023 - In this tutorial, we'll explore the basics of the urllib library, focusing on the urllib.request module, which allows you to make GET and POST requests, read server responses, and handle errors.
🌐
Python Programming
pythonprogramming.net › urllib-tutorial-python-3
Python urllib tutorial for Accessing the Internet
Here is the first and easiest example of using urllib. We just need to import urllib.requests. From there, we assign the opening of the url to a variable, where we can finally use a .read() command to read the data.
🌐
DEV Community
dev.to › ultrainstinct05 › using-the-python-urllib-module-for-making-web-requests-5hkm
Using the python urllib module for making web requests. - DEV Community
December 29, 2019 - So if you actually access this todo by doing a GET request as explained in the previous section, it will return a 404 error. We use a PUT request if we need to modify a certain resource on the server. Let's see how to do that · import json import urllib.request # This is our Todo data = { "userId": 1, "id": 1, "title": "This is a PUT request", "completed": False } # Dump the todo object as a json string data = json.dumps(data) req = urllib.request.Request(url = 'https://jsonplaceholder.typicode.com/todos/1', data = bytes(data.encode("utf-8")), method = "PUT") # Add the appropriate header.
🌐
Python
docs.python.org › 3.4 › library › urllib.request.html
21.6. urllib.request — Extensible library for opening URLs — Python 3.4.10 documentation
If the url uses the http: scheme identifier, the optional data argument may be given to specify a POST request (normally the request type is GET). The data argument must in standard application/x-www-form-urlencoded format; see the urllib.parse.urlencode() function.
🌐
GitHub
github.com › python › cpython › blob › main › Lib › urllib › request.py
cpython/Lib/urllib/request.py at main · python/cpython
HTTPHandler performs HTTP GET and POST requests and deals with · non-error returns. The HTTPRedirectHandler automatically deals with · HTTP 301, 302, 303, 307, and 308 redirect errors, and the · HTTPDigestAuthHandler deals with digest authentication. · urlopen(url, data=None) -- Basic usage is the same as original · urllib.
Author   python
🌐
GitHub
github.com › node-modules › urllib
GitHub - node-modules/urllib: Request HTTP(s) URLs in a complex world.
import { strict as assert } from 'assert'; import { MockAgent, setGlobalDispatcher, request } from 'urllib'; const mockAgent = new MockAgent(); setGlobalDispatcher(mockAgent); const mockPool = mockAgent.get('http://localhost:7001'); mockPool .intercept({ path: '/foo', method: 'POST', }) .reply(400, { message: 'mock 400 bad request', }); const response = await request('http://localhost:7001/foo', { method: 'POST', dataType: 'json', }); assert.equal(response.status, 400); assert.deepEqual(response.data, { message: 'mock 400 bad request' });
Starred by 742 users
Forked by 124 users
Languages   TypeScript 99.0% | JavaScript 1.0% | TypeScript 99.0% | JavaScript 1.0%
🌐
ProxiesAPI
proxiesapi.com › articles › accessing-websites-in-python-with-urllib-request-urlopen
Accessing Websites in Python with urllib.request.urlopen | ProxiesAPI
import urllib.request response = urllib.request.urlopen('http://python.org') print(response.status) # 200 means success print(response.getheaders()) # print headers print(response.msg) # print status msg
🌐
Narkive
comp.lang.python.narkive.com › GW2iEwKk › urllib-request-vs-requests-get
Urllib.request vs. Requests.get
TBH though, I'd just recommend using requests, unless you specifically need to avoid the dependency :) ChrisA ... Permalink Cloudflare, for whatever reason, appears to be rejecting the `User- Agent` header that urllib is providing:`Python-urllib/3.9`. Using a different `User-Agent` seems to get around the issue: import urllib.request req = urllib.request.Request( url="https://juno.sh/direct-connection-to-jupyter-server/", method="GET", headers={"User-Agent": "Workaround/1.0"}, ) res = urllib.request.urlopen(req) Paul
🌐
Python
docs.python.domainunion.de › 3 › library › urllib.request.html
urllib.request — Extensible library for opening URLs
Otherwise, if resolve_host is set to true, the authority is resolved using socket.gethostbyname() and discarded if it matches a local IP address (as per RFC 8089 §3). If the authority is still unhandled, then on Windows a UNC path is returned, and on other platforms a URLError is raised. This example shows the function being used on Windows: >>> from urllib.request import url2pathname >>> url = 'file:///C:/Program Files' >>> url2pathname(url, require_scheme=True) 'C:\\Program Files'