Using YQL and Jquery to check URL validity
The answer in this post Use jQuery to check if a URL on another domain is 404 or not? shows how to use YQL in Jquery to check if URL is valid or not. However, I can't get this to work for me. The only difference I can think of is that my URL is a tex开发者_如何学Pythont file (http://mycrossdomain.com/sometext.txt) and not HTML.I think the YQL query needs to be adjusted accordingly. Any help is appreciated.
You can create a very simply data table to bring back precisely what you need with your own custom YQL queries. For example, here is a table for retrieving the headers and status for an URL.
An example table could look like: http://github.com/salathe/yql-tables/blob/master/url/status.xml
You would use it like:
use "http://github.com/salathe/yql-tables/raw/master/url/status.xml" as url.status;
select url, status from url.status where url="http://developer.yahoo.com/";
Ideally, a HTTP HEAD request would be used but AFAIK there is no way for YQL execute to do that at this time.
精彩评论