how to change the ip address in the url.
requests.get('http://192.168.200.10:5525/system.cgi', headers=headers, params=params)
I try this code but nothing comes out
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)
CodePudding user response:
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)
CodePudding user response:
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)