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