[英]TimeoutError: [WinError 10060] A connection attempt failed
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
TimeoutError: [WinError 10060] 连接尝试失败,因为连接方在一段时间后没有正确响应,或者因为连接的主机没有响应而建立连接失败
I did everything I can think of to fix this but maybe im not fully understanding this error.我做了我能想到的一切来解决这个问题,但也许我没有完全理解这个错误。 Please help me out.
请帮帮我。
Here is the code and link.这是代码和链接。
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)
Use selenium
instead:改用
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.