Skip to content
Advertisement

BeautifulSoup extract conditioned digit coloured by css

I successfully get the data from this table from THRIVEN : enter image description here

But as you can see, at the Net% column, those values negative/positive are determined by some CSS (which I believed, and I couldn’t find them where they are located).

How can I extract those data and put them into my Excel as negative/positive numbers? Below is my current code :

JavaScript

Giving me :

enter image description here

Note that the Revenue and Profit/Loss colors are conditioned in Excel itself.

EDIT :

Finally I can achieve this by :

JavaScript

Thanks to @HedgeHog suggesting the solutions! :D

Advertisement

Answer

Check the class of the button to differentiate positive or negative value:

JavaScript

Example

JavaScript

Output

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement