import os import urllib # run command to get wlan0 internal IP address command = os.popen('ifconfig | grep -A1 wlan0') # ready the command data client_ip = command.read() # put the internal IP address into the query params query = { 'client_ip' : client_ip } url = "http://domain/path/to/some.php?"+urllib.urlencode(query) # print the final url print url