我尝试登录后获取网站的源数据,但无法登录以获取源代码。该网址是我登录后看到的 网页。如果我使用chrome登录,我可以使用url
转到我需要获取源数据的位置。
我不断收到多个错误,主要是握手错误:
" sslv3警报握手失败","坏握手"," urllib3.exceptions.MaxRetryError",我认为主要错误是
追踪(最近一次通话): 文件" C:\ Users \ bwayne \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ urllib3 \ contrib \ pyopenssl.py",第441行,在wrap_socket中 cnx.do_handshake()
文件" C:\ Users \ bwayne \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ OpenSSL \ SSL.py",第1716行,在do_handshake中 self._raise_ssl_error(self._ssl,result)
文件" C:\ Users \ bwayne \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ OpenSSL \ SSL.py",第1456行,_raise_ssl_error _raise_current_error()
文件" C:\ Users \ bwayne \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ OpenSSL_util.py",第54行,在exception_from_error_queue中 提出exception_type(错误)
OpenSSL.SSL.Error:[(' SSL例程',' ssl3_read_bytes',' sslv3警报握手失败')]
在处理上述异常期间,发生了另一个异常:
import requests, sys
import ssl
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
ctx.options |= ssl.OP_NO_SSLv2
ctx.options |= ssl.OP_NO_SSLv3
ctx.options |= ssl.OP_NO_TLSv1
ctx.options |= ssl.OP_NO_TLSv1_1
class Ssl3HttpAdapter(HTTPAdapter):
def init_poolmanager(self, connections, maxsize, block=False):
self.poolmanager = PoolManager(num_pools=connections,
maxsize=maxsize,
block=block,
ssl_version=ssl.PROTOCOL_TLSv1)
url = "www.thewebsite.com"
def do_requests(url):
payload = {'Username': 'myName', 'Password': 'myPass'}
headers = {'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Mobile Safari/537.36'}
with requests.Session() as s:
s.mount(url,Ssl3HttpAdapter())
p = s.post(url, headers=headers, data=payload, verify=False)
def main(url):
do_requests(url)
main(url)
我如何登录?我已经检查过双重和三重检查HTML名称是否正确: