0

我需要登录到一个 URL(url),然后使用 lib 文件请求和重定向重定向到另一个 URL(url1)。请帮我处理这段代码

 url ="https://team/login.html"
 url1="https://team/queue.html"

这是我用来从 url1 获取 HTML 代码的代码

我需要登录到“url”,然后重定向到“url1”并在 sample1.txt 文件中获取其 HTML 代码

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()  
4

0 回答 0