'how to change the IP address in the url

how to change the ip address in the url.

requests.get('http://192.168.200.10:5525/system.cgi')

I try this code but nothing comes outtrybut nothes o

import requests
from secimc import password

ipaddr = '192.168.100.115'

resp = requests.get('http://ipaddr:5525/system.cgi')



Solution 1:[1]

should work just fine

import requests
from sec import password

ipaddr = '192.168.100.115'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0',
    'Authorization': password,
}

params = (
    ('time', '66'),
)

resp = requests.get('http://'+ipaddr+':5525/system.cgi', headers=headers, params=params)

Solution 2:[2]

In your case ipaddr in the url is just a part of the string. To use it as variable try to use f-string:

resp = requests.get(f'http://{ipaddr}:5525/system.cgi', headers=headers, params=params)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bastien B
Solution 2 oklymeno