IonicaBizau / scrape-it

🔮 A Node.js scraper for humans.

Home Page:http://ionicabizau.net/blog/30-how-to-write-a-web-scraper-in-node-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get background-image:url from style class?

wayneconnolly opened this issue · comments

This HTML has blank spaces and carraige returns in the class name(I didn't write it...) and it doesn't allow me to target it to return the bg image url.

<div class="PlayableMedia-player
        
        " data-playable-media-url="" data-use-react-player="" data-use-b-version-of-react-player="" data-use-player-precache="" data-border-top-left-radius="" data-border-top-right-radius="" data-border-bottom-left-radius="" data-border-bottom-right-radius="" style="padding-bottom: 100.0%; background-image:url('https://pbs.twimg.com/ext_tw_video_thumb/1169754368993890310/pu/img/Fu_o2uc8IclJ1fW5.jpg')">

I tried the following but it returns null. Any tips would be very helpful

		  , vidImg: {
		        selector: "div.PlayableMedia-player"
		      , attr: "style"
		    }

Thanks!

It's ok - i was sending the wrong html in. Now I have the code above working fine.