我需要登录到URL(URL),然后使用lib文件请求并重定向到另一个URL(url1)。请使用此代码帮助我
url ="https://team/login.html"
url1="https://team/queue.html"
这是我用来从url1获取HTML代码的代码
我需要登录“ url”,然后重定向到“ url1”,并将其HTML代码保存在sample1.txt文件中
from requests import Session
url ="https://team/login.html"
url1="https://team/queue.html"
with Session() as s:
login_data ={"username:": "user", "password:": "12345" , "rememberMe:": "on"}
s.post(url,login_data, allow_redirects=True)
home_page = s.get(url1)
tmt= home_page.content
file1 =open('sample1.txt','w+')
file1.writelines(str(tmt))
file1.close()
mylines=[]
file2=open('sample1.txt','rt')
for myline in file2:
mylines.append(myline)
file2.close()