[英]I need to open web page using Python
I need to open a website, log in to it, and after it displays opened webpage (some DIVs) in my Flask web server.我需要打开一个网站,登录它,然后在我的 Flask web 服务器中显示打开的网页(一些 DIV)。
Website is https://home.solarman.cn/login.html网址是https://home.solarman.cn/login.html
I tried this code for login我尝试使用此代码进行登录
import requests
POSTLOGINURL = 'https://home.solarman.cn/login.html'
REQUESTURL = 'https://home.solarman.cn/main.html'
payload = {
'username': '',
'pass': ''
}
with requests.Session() as session:
post = session.post(POSTLOGINURL, data=payload)
r = session.get(REQUESTURL)
print(r.text)
import requests
target = "https://home.solarman.cn/main.html"
data = {
"userName": "user@user.com",
"userNameDisplay": "user@user.com",
"password": "yourpass",
"lan": "2",
"domain": "home.solarman.cn",
"userType": "C"
}
def main(url):
with requests.Session() as req:
r = req.post(url, data=data).json()
print(r)
r = req.get(target)
print(r)
main("https://home.solarman.cn/cpro/login/validateLogin.json")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.