from grab import Grab
g=Grab()
infile=open('test.txt','r')
inputs=[line for line in infile.readlines().split('\n')]
for input in inputs:
try:
g.go('www.some.site.com')
g.form_fields('form1',input)
except:
print('Ой, все')
if g.response.code==200:
body=g.response.body
from grab import Grab
g = Grab()
sample_url = 'some_url'
xpath_part= 'some_xpath'
resp = g.go(sample_url).body
result = resp.xpath(some_xpath).text()
print(result)