打算在http://app1.sfda.gov.cn/上獲取一些數據整理起來,想用python.requests實現(xiàn)一個小爬蟲來獲取數據,但是python.requests會一直報('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer')的錯誤,但是那個網站是的的確確能上的,各位有知道我錯在哪里嗎,謝謝??代碼如下:import requestsdef testLoadRequest(): officialHeader = { 'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) ' 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36', 'referer':'http://app1.sfda.gov.cn/', 'Upgrade-Insecure-Requests':'1' } officialUrl = 'http://app1.sfda.gov.cn'; try: officialRequest = requests.get(officialUrl, headers= officialHeader) print(officialRequest.content) except Exception as e: print(e)testLoadRequest()
為什么有些網站能顯示內容但python.requests卻爬不出數據呢?
慕田峪7331174
2018-09-04 13:18:19