我有这个网站,我需要通过python脚本登录,并且它不应该打开浏览器。我尝试使用请求(此站点上有很多示例),但是它不起作用,并且给出了登录页面本身的html。还有一种方法可以模拟ck
<head></head>
<body class="page_bg">
<h1 align='center'>Machine 1</h1>
<form action='welcome.php' method='POST'>
<table align='center'>
<tr>
<th colspan="2"><h2 align="center">Login</h2></th>
</tr>
<tr>
<td><b>Username</b></td>
<td><input type="text" name="uname"></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="pwd1"></td>
</tr>
<tr>
<td align="right" colspan="2"><input type="submit" name="login" value="login"></td>
</tr>
</table>
</form>
</body>
</html>
我尝试过的代码
import requests
from bs4 import BeautifulSoup
login_data = {
'uname': 'admin',
'pwd1': '<mypassword>',
'op': 'Login'
}
with requests.Session() as s:
url = 'https://projectdivesy.000webhostapp.com/'
r = s.get(url)
soup = BeautifulSoup(r.content, 'lxml')
r = s.post(url, data=login_data)
print(r.content)
答案 0 :(得分:0)
您需要将请求发送到ax = get_ax(1)
r = results[0]
visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'],
dataset.class_names, r['scores'], ax=ax)
页
welcome.php