簡體   English   中英

TimeoutError: [WinError 10060] 連接嘗試失敗

[英]TimeoutError: [WinError 10060] A connection attempt failed

TimeoutError: [WinError 10060] 連接嘗試失敗,因為連接方在一段時間后沒有正確響應,或者因為連接的主機沒有響應而建立連接失敗

我做了我能想到的一切來解決這個問題,但也許我沒有完全理解這個錯誤。 請幫幫我。

這是代碼和鏈接。

import urllib.request
import requests

link = "https://www1.nseindia.com/live_market/dynaContent/live_watch/option_chain/optionKeys.jsp?symbolCode=242&symbol=RELIANCE&symbol=RELIANCE&instrument=OPTSTK&date=-segmentLink=17&segmentLink=17"


user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'
request = urllib.request.Request(link,headers={'User-Agent': user_agent})
response = urllib.request.urlopen(request)
html = response.read()
print(html)

改用selenium

from selenium import webdriver
import os

browser = webdriver.Chrome(executable_path=os.path.abspath(os.getcwd()) + "/chromedriver")
link = "https://www1.nseindia.com/live_market/dynaContent/live_watch/option_chain/optionKeys.jsp?symbolCode=242&symbol=RELIANCE&symbol=RELIANCE&instrument=OPTSTK&date=-&segmentLink=17&segmentLink=17"
browser.get(link)
context = browser.page_source

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM