Bing Image Search API v5-contentURL重定向 [英] Bing Image Search API v5 - contentURL Redirect

查看:90
本文介绍了Bing Image Search API v5-contentURL重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望您能为我提供帮助,我正在尝试使用Bing Image Search API,到目前为止一切都很好,只有一件事我不理解,contentURL是一种重定向,应该在图像url处从来源网站上至少可以看到文档所说的内容(以及搜索的先前版本).我尝试使用趋势图像,那里的contentURL应该是那里的样子.因此,仅对于图像搜索可以重定向:

I hope you could help me, I'm trying to use the Bing Image Search API and everything is fine so far, there's just one thing that I don't understand, contentURL is a redirection, where should be the image url from the source website at least thats what documentation says (and the previous version of the search). I tried with Trending images and there the contentURL is how it should there. So only for Images search gives a redirection:

来自jSON响应的第一个对象的contentURL

contentURL from first object of jSON Response

"contentUrl": "http://www.bing.com/cr?IG=9BF011209A7349ACAE17F77A728C2EBB&CID=26ACC54E26896146357ACC8E27B86066&rd=1&h=mgBegiuCUD3JUTxAAdzTjPyARNluGjEKSz9UCvuA2oM&v=1&r=http%3a%2f%2f2.bp.blogspot.com%2f-hqcXd4UtCrE%2fTqlVvAt7XJI%2fAAAAAAAAB54%2fw6WemH9gecU%2fs1600%2fcar%2bwallpapers%2bhonda%2b194.jpg&p=DevEx,5008.1",

这是我的要求:

https://api.cognitive.microsoft.com/bing/v5.0/images/search?q=car

我使用了Open API Test Console,只是为了验证我的代码没有问题,并且结果是相同的.任何人都遇到此问题或知道如何解决?在这种情况下,我需要图片的原始网址.

I used Open API Test Console, just to verify that there's nothing wrong with my code, and the results are the same. Anyone encountered this or know how to fix it? I need the original url of the image in the case.

PS.我可以剪断字符串并获取主要地址,但是我认为这不是一个好主意,因为如果是错误或他们对其进行了更改,它将无法正常工作,因此有没有办法获取原始网址图像?

PS. I can cut the string and take the main address, but I don't think this is a good idea, because if it's a bug or they change it, it won't work, so is there a way to get original URL of the image?

推荐答案

Patrick是正确的.对URL进行编码是行业标准的最佳实践,它可以实时提高搜索引擎结果的相关性,从而在不增加服务成本的情况下增加服务的价值.但是,它确实提出了必要的权衡,这就是您所描述问题的原因.

Patrick is right. Encoding the URLs is the industry standard best-practice for improving the relevancy of search-engine results in real time, thus increasing the value of the service without needing to increase its cost. It does however, present a necessary tradeoff which is the cause of the problem you've described.

也就是说,返回URL似乎旨在保持一致且可预测的格式编码.我个人已经解析了指向明文的1k链接,并且通过实施一些简单的规则,并没有却创建了一个无效链接.您对将来可能发生的更改提出了一个很好的建议,但是到目前为止,还没有任何迹象表明它们将要更改格式,并且URL相对来说要解析为纯文本相对来说是微不足道的.

That said, the return URLs appear to be designed to keep encoding in a consistent and predictable format. I have personally parsed >1k links to plaintext and, by implementing a few simple rules, have not yet created a single invalid link. You raise a good point about the potential for future changes, however as of now there hasn't been any indication they're going to change the format, and the URLs are currently relatively trivial to parse to plaintext.

这篇关于Bing Image Search API v5-contentURL重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆