I'm trying to use URLLIB2 to open a URL and read back the contents into an array. The issue seems to be that you cannot use string interpolation in a URL that has formating characters such as %20 for space, %3C for '<'. The URL in question has spaces and a bit of xml in it.
My code is pretty simple, looks something like this:
#Python script to fetch NS Client Policies using GUID
import sys
import urllib2
def GetPolicies(ns, guid):
ns = sys.argv[1]
guid = sys.argv[2]
fetch = urllib2.urlopen('http://%s/Altiris/NS/Agent/GetClientPolicies.aspx?xml=%3Crequest%20configVersion=%222%22%20guid=%22{%s}%22') % (ns, guid)
I've shortened the URL for brevity but you get the general idea, you get a 'Not enough arguments for format string' error since it assumes you're wanting to use the %3, %20, and other things as string interpolations. How do you get around this?