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)
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)
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.