Web Scraping for a Site that Uses Inline Styles

node , javascript , scraping United States
  • 11 months ago

    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@[email protected]" 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.

  • 11 months ago

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

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann