Since i have a script that uses a lot of http requests, i decided to create a function to do that ( instead having the same block of code over, and over… ). But the problem im facing, is how i can return the html output from file_a.py to file_b.py? Since i need the output to parse some results?
file_a.py
def invokeServer(proxyUser,proxyPass,proxyHost,iserver,isService,login,password):
proxy_auth = "http://"+proxyUser+":"+proxyPass+"@"+proxyHost
proxy_handler = urllib2.ProxyHandler({"http": proxy_auth})
opener = urllib2.build_opener(proxy_handler)
opener = urllib2.build_opener()
urllib2.install_opener(opener)
request = urllib2.Request("http://"+iserver+""+isService)
base64string = base64.encodestring('%s:%s' % (login, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
response = urllib2.urlopen(request)
html= response.read()
return html
file_b.py
from file_a import invokeServer
invokeServer(proxyUser,proxyPass,proxyHost,iserver,isService,login,password)
# From this line bellow, i need to use the html result from file_a.py
doc = LH.fromstring(html)
LE.strip_tags(doc,'b')
data_list = doc.xpath("//td[text()='triggerNameList']/following-sibling::*")[0]
triggerName = data_list.xpath("//td[text()='triggerName']/following-sibling::*/text()")
Thanks in advance.
store it in a variable: