bounty将在12小时后过期。回答此问题可获得+500声望奖励。showkey正在寻找来自信誉良好的来源的**答案 *。
我在vps上搭建了一个vmess协议的代理服务器,在本地搭建了一个vmess协议的代理客户端。yahoo website
可以通过浏览器中的2081端口打开(在firefox中设置http和https的代理端口2081),端口2081提供http(s)代理。
端口2080提供socks 5代理服务:
url="https://query1.finance.yahoo.com/v7/finance/download/MSFT"
curl --socks5-hostname 127.0.0.1:2080 $url -o msft.txt
字符串
我现在可以下载yahoo数据了,希望用这些代理使用yfinance库。
试试方法1:
import yfinance as yf
msft = yf.Ticker("MSFT")
msft.history(proxy="http://127.0.0.1:2081")
msft.history(proxy="https://127.0.0.1:2081")
msft.history(proxy="socks5://127.0.0.1:2080")
型
他们都不能工作!
试试方法二:
debian@debian:~$ export all_proxy=socks5://127.0.0.1:2080
debian@debian:~$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yfinance as yf
>>> msft = yf.Ticker("MSFT")
>>> msft.history()
Failed to get ticker 'MSFT' reason: SOCKSHTTPSConnectionPool(host='query2.finance.yahoo.com', port=443): Read timed out. (read timeout=10)
MSFT: No price data found, symbol may be delisted (period=1mo)
Empty DataFrame
Columns: [Open, High, Low, Close, Adj Close, Volume]
Index: []
型export https_proxy=http://127.0.0.1:2081
的问题。
试试方法三:
#pip install Pysocks first
import socket
import socks
socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 2080)
socket.socket = socks.socksocket
import yfinance as yf
msft = yf.Ticker("MSFT")
msft.history()
型
错误信息:
Failed to get ticker 'MSFT' reason:
HTTPSConnectionPool(host='query2.finance.yahoo.com', port=443):
Max retries exceeded with url: /v8/finance/chart/MSFT?
range=1d&interval=1d&crumb=tCwRGfMyTIV (Caused by
NewConnectionError('<urllib3.connection.HTTPSConnection object at
0x7f78d3f89730>: Failed to establish a new connection: [Errno -2]
Name or service not known'))
型
那怎么修?
已更新:
x1c 0d1x的数据
通过代理请求:
的
yfinance over proxy
的
雅虎不再提供任何服务。
的
bash命令和python的最新尝试:
x1c4d 1x的
1条答案
按热度按时间7kjnsjlb1#
我没有代理服务器,但你可以试试这个,看看你是否可以访问该网站?
字符串
也试试这个,确保你有最新版本的yfinance,在命令行中使用
pip install yfinance --upgrade --no-cache-dir
,然后运行这个。型
或者,您也可以尝试
型
如果有错误,请告诉我。
请尝试以下操作,看看您的代理是否可以访问。请使用代理地址和端口。
型
也可以尝试使用没有代理的普通yfinance方法,并显示输出。
试试这个方法,让我知道会发生什么。
型