JavaScript Scraper not returning any values with jquery using cheerio

Trying to scrape the front page of a website (www.ozbargain.com) to return any content in the a tag that holds a reference to xbox but nothing is being returned to console. I believe the issue is with the if statement with :contains.

var fs = require('fs'),
    request = require('request'),
    cheerio = require('cheerio');

url = 'http://www.ozbargain.com.au';

request(url, function(error, response, html) {
  if (!error && response.statusCode == 200) {
    var $ = cheerio.load(html);
    if($("a:contains('Xbox')").length) {
      //console.log(this);
      var el = $(this);
      var log = el.text();
      console.log(log);
    } else {
      console.log('hey');
    }
  }
});

The html block I'm after. In particulare, I want the a tag;

<h2 class="title" id="title214252"><a target='_blank' href="/node/214252">Free on Xbox One, Xbox 360, PS3, PS4: Tales from the Borderlands (Episode 1)</a></h2>
Answer:1

The Cheerio syntax for contains is slightly different than jQuery. Ommit the single quotes around the string you're searching for an it should work:

$("a:contains(Xbox)")
Answer:2

My code below doesn't allow the API user to update only one field by passing one request property. I can remove the null at userObj, but the UI developer will have to pass existing data from the ...

My code below doesn't allow the API user to update only one field by passing one request property. I can remove the null at userObj, but the UI developer will have to pass existing data from the ...

  1. update only some columns sql
  2. mongoose update only some fields
  3. mongodb update only some fields
  4. rails update only some attributes
  5. pandas update only some rows
  6. mysql update only some columns
  7. yum update only some packages
  8. nhibernate update only some fields
  9. mvc update only some fields
  10. sql update only some rows
  11. svn update only some files
  12. mysql update only some rows
  13. sql update only some fields
  14. mysql update only some fields
  15. entity framework update only some fields
  16. hibernate update only some fields
  17. jpa update only some fields
  18. entity framework update only some properties

I'm using this basic code to hide one block of text and display another and it works well but what do I need to do to have a second click close the text again? Right now it stays open until something ...

I'm using this basic code to hide one block of text and display another and it works well but what do I need to do to have a second click close the text again? Right now it stays open until something ...

  1. javascript display hide
  2. javascript display hide div
  3. javascript display hide element
  4. javascript hide display table row
  5. javascript hide display table column
  6. javascript display show hide
  7. javascript hide display none
  8. javascript display show hide div
  9. javascript style display hide
  10. javascript css display hide
  11. javascript onclick display hide
  12. javascript style display show hide
  13. javascript hide element display none
  14. javascript display hide content

Need help to convert below JSON string into JSON object.Even string JSON is valid json (verified by https://jsonlint.com/). JSON: { "condition": "AND", "rules": [{ "id": "amount"...

Need help to convert below JSON string into JSON object.Even string JSON is valid json (verified by https://jsonlint.com/). JSON: { "condition": "AND", "rules": [{ "id": "amount"...

  1. json.parse not working
  2. json.parse not working in javascript
  3. json.parse doesn't work

I draw many circles with some loops via d3.js var line = d3.svg.line() var r = 1 var svg = d3.select("body").append("svg:svg") .attr("width", 1000) .attr("height",1000) for ( var x=0; x<...

I draw many circles with some loops via d3.js var line = d3.svg.line() var r = 1 var svg = d3.select("body").append("svg:svg") .attr("width", 1000) .attr("height",1000) for ( var x=0; x<...

  1. lenovo smart display update loop