HTTP请求在我的localhost上工作正常,但是在我的服务器上使用python请求库运行相同的HTTP请求会返回"Too Many Redirects"错误
当我进入
localhost/terminal/jfk
Run Code Online (Sandbox Code Playgroud)
在浏览器中,我按预期获得了一个json字典.
但是,当我在我的服务器上使用python请求库在python中运行以下内容时
requests.get('http://splitmyri.de/terminal/jfk')
Run Code Online (Sandbox Code Playgroud)
我从请求模块收到"Too Many Redirects"错误.
是否有任何关于导致错误的想法?或建议缩小潜在原因?
我在设置相对于sendAsynchronousRequest:queue:completionHandler:
方法(NSURLConnection
类)的正确配置方面遇到了一些困难.
我的方案如下:
我建立了一个管理不同NSURLConnection
s 的单例类.这个单例符号有一个NSOperation Queue
(被叫downloadQueue
),它向Web服务器发出请求并检索字符串路径(1).完成后,该路径用于下载Web服务器(2)中的文件.最后,当文件被正确下载后,我需要更新UI(3).
我只想出了第一个请求:我可以通过它下载路径.你能建议我一个方法来执行其他两个步骤吗?
这里几个问题:
下载队列(downloadQueue
)不是主要的,是否可以在该队列中打开新的NSURLConnection?换句话说,这是正确的吗?(参见代码片段中的注释)
如果前一个问题是正确的,我如何获取主队列并更新UI?
这里我用来执行第一步的代码片段downloadQueue
是一个可以通过访问器方法获得的实例变量(@property
/ @synthesized
);
// initializing the queue...
downloadQueue = [[NSOperation alloc] init];
// other code here...
[NSURLConnection sendAsynchronousRequest:urlRequest queue:[self downloadQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if([data length] > 0 && error == nil) {
// here the path (1)
// how to perform a second connection?
// what type of queue do I …
Run Code Online (Sandbox Code Playgroud) networking nsurlconnection nsoperationqueue ios http-request
我想索引本地数据库中的文件,但我不明白如何识别每个单独的文件.例如,如果我将文件路径存储在数据库中,那么如果移动或删除文件,该条目将不再有效.我想有一些方法可以唯一识别文件,无论发生什么事情,但我没有成功使用谷歌.
这将特别针对*nix/Linux和ext4,所以请不要特别针对windows或ntfs或类似的东西.
我试图获取一个具有该字符的请求字符串,#
并且我的参数只有#
.但问题是我需要有这个角色,不能删除它.
任何的想法?
我正在尝试使用requests.get请求多个URL.这是我开始使用的
for number in range(1,10):
page =requests.get('http://google.com/page'+str(number),'http://yahoo.com/page'+str(number))
Run Code Online (Sandbox Code Playgroud)
但我得到的是一个错误TypeError:get()只需要1个参数(给定2个)
我也尝试过这个
url=['','http://google.com/page','http://yahoo.com/page']
for number in range(1,10):
page = requests.get(url[number]+str(number))
Run Code Online (Sandbox Code Playgroud)
这给了我
IndexError: list index out of range
Run Code Online (Sandbox Code Playgroud) http-request ×4
python ×2
dns ×1
file ×1
filesystems ×1
get ×1
ios ×1
java ×1
linux ×1
networking ×1
query-string ×1
redirect ×1
servlets ×1