我尝试运行这段 Python 代码(使用 requests 库)从 NASDAQ.com 检索特斯拉一年的历史市场数据
dataURL = https://www.nasdaq.com/api/v1/historical/TSLA/stocks/2019-05-22/2020-05-21
quotesReq = requests.get(dataURL, allow_redirects = True)
Run Code Online (Sandbox Code Playgroud)
尽管能够通过 Web 浏览器访问 URL 并下载预期的“.csv”文件,但我的 Python 代码会产生超时错误。
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(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', None, 10060, None))
Run Code Online (Sandbox Code Playgroud)
这是因为 NASDAQ.com 采取了反抓取措施,还是我在请求中遗漏了某些信息?任何解决问题的帮助将不胜感激。
当我在下面的代码中调用我的SegTree结构的构造函数时,我不断得到一个非零的退出代码.当我注释掉初始化结构的行时,程序运行没有问题.有人可以解释为什么会发生这种情况以及如何修复我的代码吗?
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>
using namespace std;
struct SegTree{
int N;
long long tree [1<<20], arr [1<<20];
SegTree(int x){ N = x; }
};
int main(){
SegTree st(len);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
请帮助,并提前感谢!
编辑:我的问题不是数组的大小,正如我在评论中提到的那样.我可以创建数组并在将它们放在结构外部时运行代码.