2017-09-23 153 views
0

我正在編寫一個簡單的腳本,在LinkedIn上無需登錄即可看到公開的個人檔案。 下面是我的代碼來獲取美麗的頁面。我也使用公共代理。LinkedIn HTTP錯誤999 - 請求被拒絕

import urllib.request, urllib.error 
from bs4 import BeautifulSoup 

url = "https://www.linkedin.com/company/amazon" 
proxy = urllib.request.ProxyHandler({'https': proxy, }) 
opener = urllib.request.build_opener(proxy) 
urllib.request.install_opener(opener) 
hdr = { 
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3218.0 Safari/537.36', 
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 
    'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 
    'Accept-Encoding': 'gzip, deflate, br', 
    'Accept-Language': 'en-US,en;q=0.9,hi;q=0.8', 
    'Connection': 'keep-alive'} 
req = urllib.request.Request(url, headers=hdr) 
page = urllib.request.urlopen(req, timeout=20) 
self.soup = BeautifulSoup(page.read(), "lxml") 

但它引發「HTTPError 999-請求被拒絕」錯誤。這只是爲了測試目的,直到我通過合作伙伴計劃獲得訪問權限。

我在做什麼錯?請幫忙。

回答

0

你沒有做錯任何事,LinkedIn黑名單雲服務器的IP地址,以防止「竊取」他們的數據。可疑的做法,但這是如何。

相關問題