What I'm trying to do:
Output the value of a self.out var in a way that I can still use in another method.
The code
if self.path_object is not None:
dictpath = {}
for path in self.path_object:
parsed = urlparse(path.pathToScan)
if parsed.query:
self.params = parsed.query.split('&', 2)
self.out = list(map(lambda v: v.split("=")[0] +"=" + str(self.fooz), self.params))
dictpath[parsed.geturl()] = self.out
print dictpath
This code brings in a set of paths (via path_object), it then parses those paths on the & symbol and attaches the value of self.fooz to it, then puts it into a dictionary and outputs the results.
Result Its currently outputting a list like (added spacing for readability):
{
u'www.somesite.com/param.php?id=317':
u'id=[<self.fooz>, <self.fooz>, <self.fooz>,<self.fooz>, <self.fooz>, <self.fooz>]',
u'somesite.com/param.php?id=911¶m2=6¶m3=cat':
[u'id=[<self.fooz>, <self.fooz>, <self.fooz>,<self.fooz>, <self.fooz>, <self.fooz>]',
u'param2=[<self.fooz>, <self.fooz>, <self.fooz>,<self.fooz>, <self.fooz>, <self.fooz>]',
u'param3=[<self.fooz>, <self.fooz>, <self.fooz>,<self.fooz>, <self.fooz>, <self.fooz>]']
}
My question is, how can I access this output in another method, so that I can loop through each parameter like:
u'somesite.com/param.php?id=<<<<<self.fooz>>>>>¶m2=6¶m3=cat':
then
u'somesite.com/param.php?id=911¶m2=<<<<<self.fooz>>>>>¶m3=cat
and then so on for each parameter in a path.
So, far I have tried requesting a url from the present output, but requests isn't allowing a path to be requested like <self.fooz> as its not a valid url (e.g. including somesite.com or http://somesite.com).
Any help is greatly appreciated.
Thank you SO much!