我想从一些网页中挑出几行信息。我想要(或者我想要)打开网页,遍历行,检查每个关键字,当我找到它时复制我想要的信息。
这些页面需要一个会话。
def getpage()
home = 'website'
exstension1 = '/input/page'
extension2 = '/output/page'
indexnumber = '11100'
sess = requests.Session()
getter = sess.get(home+extension1)
payload = {'foo':'bar','indexnumber':indexnumber}
getter = sess.post(home+extension2,data=payload)
return sess
正如我试图在标题中所说,我需要一个 readlines() 方法用于 .get()
a.get(somePage)###Now could I put...###.readlines()
####or
a.get(somePage).text.readlines()###?
###I don't think I want the following, for performance reasons, correct me if I am wrong
F = open(someNewFile,mode='w')
F.write(a.get(somePage).text)
F.close()
F = open(thatFileIJustMade).readlines()###All that just to turn it into a File on which I can use readlines?
谢谢
当我尝试
a.get(somePage).readlines()
我明白了
AttributeError: Response Object Doesn't have attribute readlines