View on GitHub

xReader v0.0.78a [DEMO]

ACCESS RESOURCES WITHOUT RESTRICTIONS BY YQL

xReader

xReader is a javascript function for accessing other resources without restrictions by YQL.

lift restrictions!

xReader Usage
<script src="http://kincrew.github.com/xReader/xReader.full.js"></script>
<script type="text/javascript">
xReader("http://www.yahoo.com/", function(data) {
    alert(data.content);
})
RUN
</script>

Download xReader.micro.js or xReader.full.js.

xReader features

xReader API

xReader("URL", "CSS", callback, option)
- [string] URL
- [string] CSS - optional
- [function] callback(data)
data = {
    headers : [obeject],
    content : [string|object]
    format  : [string]
    original : [obeject]
    redirect : {
        from    : [string],
        to      : [string],
        status  : [string]
    },
    url     : [string],
    date    : [date],
    statue  : [string],
    status  : [string],
    error   : [obeject],
    YQL     : [obeject]
    xReader : [obeject],
    option  : [obeject],
    maxAge  : [number]
}
- [object] option - optional
OPTIONDESCVALUE
cacheBurstcheck this [YQL BLOG]false | true
charsetcaharset (Wait plz)undefined | [string]
contentdata (Wait plz)undefined | [string]
contentTypecontent-type (Wait plz)undefined | [string]
cookiecookie undefined | [object]
csscss selectorundefined | [string]
diagnosticsYQL diagnostics false | true
formatcontent format "text" | "json" | "dom" | "dom2"
forceCharsetforce Charsetundefined | [string]
fallbackCharsetfallback Charset"utf-8, euc-kr, iso-8859-1" | [string]
headershttp request headersundefined | [object]
linkmethod from xReader to YQL/td>"auto" | "ajax" | "jsonp"
methodhttp request method"get" | "post" | "head" | "put"
maxAgemaxAge by the url (sec)undefined | [number]
maxAgeGlobalmaxAge (sec)undefined | [number] | "reset"
queryYQL Queryundefined | [string]
paramundefined | [object]
refererrefererundefined | [string]
sslYQL SSL false | true
table choose other table "http://kincrew.github.com/xReader.xml" | [string]
targetundefined | [object]
tidyjson false | true
timeouttimeout (ms)10000 | [number]
uaua undefined | "current" | [string]
xpathxpathundefined | [string]

Simple Demo

HTML / XML
/* Headline from The Wall Street Journals*/
xReader("wsj.com", "#main_content h2 a/text()", function(data){
    alert(data.content);
})
RUN

[TIP] If you want get only text, add "/text()"
[INFO] auto redirection : wsj.com -> http://online.wsj.com/ -> http://online.wsj.com/home-page

JSON / JSONP
/* tag : cat from flickr */
var url = "http://api.flickr.com/services/feeds/photos_public.gne?";
url += "tags=cat&tagmode=any&format=json";
xReader(url, function(data){
    var items = data.content.items;
    var html = "";
    for (var i=0; items.length > i ;i++ ) {
        html += "<div>" + items[i].description + "</div>";
    }
    return html;
},
{
    format : "json", // type
    target : document.getElementById("exDemoResult4") // output target
}
)
RUN
powered by Yahoo! Query Language