Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用代理的Linkedin请求_Python_Python Requests - Fatal编程技术网

Python 使用代理的Linkedin请求

Python 使用代理的Linkedin请求,python,python-requests,Python,Python Requests,Linkedin在我的国家被阻止,所以我尝试使用代理登录 import requests from bs4 import BeautifulSoup p = {'http': 'http://54.167.184.222:3128', 'https': 'https://54.167.184.222:3128'} client = requests.Session() client.proxies.update(p) HOMEPAGE_URL = 'https://linkedin.com/

Linkedin在我的国家被阻止,所以我尝试使用代理登录

import requests
from bs4 import BeautifulSoup
p = {'http': 'http://54.167.184.222:3128', 'https': 'https://54.167.184.222:3128'}

client = requests.Session()
client.proxies.update(p)

HOMEPAGE_URL = 'https://linkedin.com/'
LOGIN_URL = 'https://www.linkedin.com/uas/login-submit'

html = client.get(HOMEPAGE_URL).content
soup = BeautifulSoup(html)
csrf = soup.find(id="loginCsrfParam-login")['value']

login_information = {
    'session_key':'Login',
    'session_password':'Password',
    'loginCsrfParam': csrf,
}

client.post(LOGIN_URL, data=login_information)
但我得到了以下错误:

Traceback (most recent call last):
  File "/home/afanasev/linkedin/lib/python3.6/site-packages/requests/adapters.py", line 324, in send
    timeout=timeout
  File "/home/afanasev/linkedin/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 506, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: hostname '54.167.184.222' doesn't match either of 'www.linkedin.com', 'linkedin.com'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/afanasev/PycharmProjects/linkedin/test.py", line 12, in <module>
    html = client.get(HOMEPAGE_URL).content
  File "/home/afanasev/linkedin/lib/python3.6/site-packages/requests/sessions.py", line 394, in get
    return self.request('GET', url, **kwargs)
  File "/home/afanasev/linkedin/lib/python3.6/site-packages/requests/sessions.py", line 382, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/afanasev/linkedin/lib/python3.6/site-packages/requests/sessions.py", line 485, in send
    r = adapter.send(request, **kwargs)
  File "/home/afanasev/linkedin/lib/python3.6/site-packages/requests/adapters.py", line 379, in send
    raise SSLError(e)
requests.exceptions.SSLError: hostname '54.167.184.222' doesn't match either of 'www.linkedin.com', 'linkedin.com'
回溯(最近一次呼叫最后一次):
文件“/home/afanasev/linkedin/lib/python3.6/site packages/requests/adapters.py”,第324行,在send中
超时=超时
文件“/home/afanasev/linkedin/lib/python3.6/site packages/requests/packages/urllib3/connectionpool.py”,第506行,在urlopen中
升起SSLError(e)
requests.packages.urllib3.exceptions.SSLError:主机名“54.167.184.222”与“www.linkedin.com”、“linkedin.com”均不匹配
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/home/afanasev/PycharmProjects/linkedin/test.py”,第12行,在
html=client.get(主页\ URL).content
文件“/home/afanasev/linkedin/lib/python3.6/site packages/requests/sessions.py”,get中第394行
返回self.request('GET',url,**kwargs)
请求中的文件“/home/afanasev/linkedin/lib/python3.6/site packages/requests/sessions.py”,第382行
resp=自我发送(准备,**发送)
文件“/home/afanasev/linkedin/lib/python3.6/site packages/requests/sessions.py”,第485行,在send中
r=适配器.send(请求,**kwargs)
文件“/home/afanasev/linkedin/lib/python3.6/site packages/requests/adapters.py”,第379行,在send中
升起SSLError(e)
requests.exceptions.SSLError:主机名“54.167.184.222”与“www.linkedin.com”、“linkedin.com”均不匹配

我以前从未在python中使用过代理,我不明白这里出了什么问题。我已经在firefox中检查了代理-它是有效的。

你在哪个国家…?好吧,如果你无法访问linkedin,那么你可以通过代理访问,这是正确的。但这些代理需要被列入白名单,因为LinkedIn对垃圾邮件代理具有强大的检测和禁止功能。请求将自动检查证书是否在一定程度上有效。若要禁用此类验证,请尝试执行:
client.get(HOMEPAGE\u URL,verify=False)
@JafferWilson Russia,很遗憾,但LinkedIn被政府为我们屏蔽了…@HamZa,它现在似乎起作用了,谢谢,我将尝试更深入一些