我受到了答案这里和python模块中的函数数据的启发,在Powershell中编写了一个函数,该函数检索两个日期之间股票的所有每日价格:
$uri = 'https://www.investing.com/instruments/HistoricalDataAjax'
$params = @{
'curr_id'= '951481'
'smlID'= '2081817'
'header'= 'STOXX 50 Volatility VSTOXX EUR Historical Data'
'st_date'= '04/13/2021'
'end_date'= '04/13/2002'
'interval_sec'= 'Daily'
'sort_col'= 'date'
'sort_ord'= 'DESC'
'action'= 'historical_data'
}
$headers = @{
'User-Agent' = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0'
'X-Requested-With'= 'XMLHttpRequest'
'Accept'= 'text/html'
'Accept-Encoding'= 'gzip, deflate'}
$res = Invoke-WebRequest -Method POST -Headers $headers -Uri $uri -Body $params -ContentType application/x-www-form-urlencoded
$res.Content > .\test.txt我的问题是,响应包含
<td colspan="7" class="arial_11 blueFont center">No results found</td>
但是它应该把所有的股票价格都归还一年以上。
作为参考,当我直接从投资和检查页面发送它时,我得到:


谢谢你的帮助!
发布于 2022-04-13 11:31:04
这个特殊示例中的问题是开始日期('st_date'='04/13/2021')是结束日期('end_date'='04/13/2002')之后的日期。因此,这个请求基本上是针对2021年以后但2002年之前的数据,这是不太合理的。
在这种情况下,将后者更改为04/13/2021之后的任何日期都可以解决这个问题。
https://stackoverflow.com/questions/71855448
复制相似问题