在http请求状态下获取选项300 [英] Getting the options in a http request status 300
问题描述
我阅读,当我收到此错误消息时,应指定更好的URL.我假设我应该在两个显示的或可访问的选项之间指定.我该怎么办?
I read that when I get this error I should specify better the url. I assume that I should specify between two displayed or accessible options. How can I do that?
在 urllib 或其教程中,我找不到任何内容.我的假设是真的吗?我可以在某处阅读可能的网址吗?
In urllib or its tutorial I couldn't find anything. My assumption is true? Can I read somewhere the possible url?
当我在浏览器中打开该URL时,我将被重定向到新的URL.
When I open this url in my browser I am redirected to a new url.
我尝试访问的网址: http://www.uniprot.org/uniprot/P08198_CSG_HALHA.fasta
我重定向到了新的网址: http://www.uniprot.org/uniprot/?query = replaces:P08198& format = fasta
The url I try to access: http://www.uniprot.org/uniprot/P08198_CSG_HALHA.fasta
The new url I am redirected: http://www.uniprot.org/uniprot/?query=replaces:P08198&format=fasta
import urllib.request
try:
response = urllib.request.urlopen(url)
except urllib.error.HTTPError as e:
if int(e.code) == 300:
# what now?
推荐答案
服务器返回状态码300来告诉您,您的请求以某种方式未完成,您将更加具体.
The status code 300 is returned from the server to tell you, your request is somehow not complete and you shall be more specific.
测试URL,我尝试从 http://www.uniprot.org/
中搜索,然后输入搜索"P08198".这导致页面 http://www.uniprot.org/uniprot/P08198
告诉我
Testing the url, I tried to search from http://www.uniprot.org/
and entered into search "P08198". This resulted in page http://www.uniprot.org/uniprot/P08198
telling me
Demerged into Q9HM69, B0R8E4 and P0DME1. [ List ]
在我看来,对某些蛋白质的查询不够明确,因为该蛋白质代码被分为子类别或子代码Q9HM69,B0R8E4和P0DME1.
To me it seems, the query for some protein is not specific enough as this protein code was split to subcategories or subcodes Q9HM69, B0R8E4 and P0DME1.
状态代码300是服务器应用发出的信号,表明您的请求有点模棱两可.您可以使其足够具体地针对特定于应用程序的方式,而与 Python
或 HTTP
状态码无关,您必须在应用程序中找到有关良好url的更多详细信息逻辑.
Status code 300 is signal from server app, that your request is somehow ambiguous. The way, you can make it specific enough is application specific and has nothing to do with Python
or HTTP
status codes, you have to find more details about good url in the application logic.
这篇关于在http请求状态下获取选项300的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!