/    Sign up×
Community /Pin to ProfileBookmark

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@[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’;

rp(url)
.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.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@makamo66authorMar 17.2020 — My code didn't work because it was requesting the wrong URL. After I changed the URL, it worked.
Copy linkTweet thisAlerts:
@VITSUSAMar 18.2020 — Great :), You got a solution.
Copy linkTweet thisAlerts:
@SebastianwoodDec 01.2020 — Hi, does anyone know if there are any websites dedicated to providing a place for people to practice web scraping and cool tools for this?
×

Success!

Help @makamo66 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...