12

I found a trickshot

// Define variables
var query = 'select * from data.html.cssselect where url="http://www.chucknorrisfacts.com/chuck-norris-top-50-facts" and css=".field-content a"';
var yqlAPI = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + ' &format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?';
$.getJSON(yqlAPI, function(r){
    console.log('Chuck Norris Facts:');
$.each(r.query.results.results.a, function(){ console.log('----------'); console.log(this.content);
}); }); 

Sound great but it doesn't work.

Found this : http://tutorialzine.com/2010/02/feed-widget-jquery-css-yql/ same problem. https://github.com/hail2u/jquery.query-yql download, unzip, run on a server and nothing.

YQL console with the first query is slow but works.

How can I use YQL with js ? Does OAuth necessary ?

update : screenshot with console

4
  • 3
    Your snippet seems to be working for me. Check it out in this fiddle. What exactly are you having problems with? When you say "How can I use YQL with js", did you mean just jquery? If that's not a requirement, you could check out YQL Query and YUI which may make this easier.
    – jbalsas
    Jan 11, 2014 at 18:37
  • Works fine for me.... Try opening dev tools go to console, and inserting it. make sure jquery is installed on the site you are trying it on.
    – Brian Noah
    Jan 12, 2014 at 2:47
  • Thank for your feedback ! Console is open… Nothing on FF, Chrome, Safari last version ; mac os X 10.9. Maybe YQL doesn't work in my country ?
    – benoît
    Jan 13, 2014 at 9:02
  • 1
    YQL has no such restrictions for any country that I'm aware of. There are some endpoints that do require you to authenticate, but only those that are dealing with things like your personal data, or your yahoo email account if you have one. The YQL developer console clearly marks which ones do & don't require authentication, and what you are attempting is not one of them.
    – shawty
    Jan 13, 2014 at 17:50

2 Answers 2

2

Apologies, I found the answer… this is not YAHOO but my local network and his gateway (modem).

I make a succesfull test using a Tethering conection. So I go to my gateway admin page.


Firewall

Web Content Filter : This page allows certain Web-oriented cookies, java scripts, and pop-up windows to be blocked by the firewall. A list of "trusted computers" can also be defined that are not subject to any filters configured. Specific Firewall features can also be enabled. It is highly recommended that the Firewall is left enabled at all times for protection against Denial of Service attacks. Go to the Parental Control page to block internet access to specific sites.

Web Features

  • Filter Proxy uncheck
  • Filter Cookies uncheck
  • Filter Java Applets uncheck
  • Filter ActiveX uncheck
  • Filter Popup Windows uncheck
  • Block Fragmented IP Packets uncheck
  • Port Scan Detection uncheck
  • IP Flood Detection uncheck
  • Firewall Protection > was checked

Unchecked the last item and now it's work ! I never had any problems with this firewall, using ajax, nas config, dlna protocol, running a mysql on local server…

To be more specific, this is a Thomson twg850-4 (rented by my ISP).

2
  • Yikes... yea those Thompson routers are a PIA, I've had many service call outs dealing with them here in the UK, Talk Talk & Plus-net seem to favor them, and they cause nothing but grief.
    – shawty
    Jan 19, 2014 at 12:05
  • Any idea how to fecth image and meta description from amazon.in/Seiko-Premier-Analog-Blue-Watch/dp/… ?
    – user7923319
    Jun 29, 2017 at 12:02
1

Don't quite know what your problem was, but your initial script works as is.

I've made a few changes to add it into a page and create the content inline, tested and running under the following browsers:

Chrome 31.0.1650.63 m Firefox 26.0 IE 11.0 IE 10.0 IE 9.0

<!DOCTYPE html />
<html>

  <head>
    <title>Chuck Norris facts</title>
  </head>

  <body>
    <h1>Chuck Norris facts</h1>

    <ul id="facts">
    </ul>

    <script src="http://code.jquery.com/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script type="text/javascript">

      $(document).ready(function ()
      {
        getFacts();
      });

      var query = 'select * from data.html.cssselect where url="http://www.chucknorrisfacts.com/chuck-norris-top-50-facts" and css=".field-content a"';
      var yqlAPI = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + ' &format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?';

      function getFacts()
      {
        $.getJSON(yqlAPI, function (r)
        {
          console.log('Chuck Norris Facts:');
          $.each(r.query.results.results.a, function ()
          {
            $('#facts').append('<li>' + this.content + '</li>');
          });
        });
      }

    </script>
  </body>

</html>

Things I would check:

your browser version and jQuery version. In my code above i've used the latest jQuery from the CDN endpoint, and i tested it in a lot of browsers.

I've got it working in the modern versions, but IE8 and less didn't work at all.

This is not a surprise though, as any jQuery after 1.9 wont work in less than IE9.

I suspect you'll also get similar issues if your Chrome/Firefox/Opera/Maxthon etc has not been updated for sometime.

Beyond that, I can't offer any more advice, as others have said, let people know what the developer tools console in your browser is showing, and even more so let us know your actual browser version.

3
  • I make a jsbin with your html jsbin.com/eLaqaYa/1/edit?html,output same result for me, any browsers and my android device 4.4 !
    – benoît
    Jan 13, 2014 at 20:29
  • your going to have to tell me EXACTLY how it failed, i just ran your JSbin by clicking on the exact link you gave me and it worked. Your going to have to start telling me and all the others on here EXACTLY what error messages your seeing in your browser, in your developer tools and anywhere else you can see anything. Do you have a web server of your own that you can try to load my HTML above from? what happens then, also try to download a tool like fiddler2, then show us exactly what that sees when making the request.
    – shawty
    Jan 13, 2014 at 21:53
  • no one is going to be able to help you further unless you start to do these things.
    – shawty
    Jan 13, 2014 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.