Web Scraping for a Site that Uses Inline Styles

The view source for the site that I am trying to scrape looks like this:

<tr class="productListing-even">
<td align="center" valign="top" class="productListing-data" style="position:relative;padding-bottom: 5px;" width="25%"><a style="position:relative;float:left;" href="product_info.php?products_id=477998&kind=2&cPath=172_23_45&description=Marquise-Floral-Crystal-Adjustable-Evening-Bracelet-/-Anklet"><img src="images/20200228/thumb/EVB1133-@BK-JET@ADJ-575H@477998@725@04@200.jpg" title="Marquise Floral Crystal Adjustable Evening Bracelet / Anklet" width="200" border="0" height="200" alt="Marquise Floral Crystal Adjustable Evening Bracelet / Anklet"><span class="small_cart" ></span></a>

I am trying to scrape the image links with the following code:

const rp = require('request-promise');
const $ = require('cheerio');
const url = 'https://www.example.com';

  .then(function(html) {
console.log($('tr.productListing-even', html).text());
console.log($('td.productListing-data > a > img', html).text());
console.log($('[width="200"]','[border="0"]','[height="200"]', html).text());
console.log($('a:style*="position:relative"', html).text());
  .catch(function(err) {
    //handle error

I am not getting any output when I run >node test.js.

My code didn’t work because it was requesting the wrong URL. After I changed the URL, it worked.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.