3

Basically exactly as the question says, I'm trying to get the background colour out from a website.

At the moment I'm using BeautifulSoup to get the HTML, but it's proving a difficult way of the getting the CSS. Any help would be great!

0

1 Answer 1

4

This is not something you can reliably solve with BeautifulSoup. You need a real browser.

The simplest option would be to use selenium browser automation tool:

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('url')

element = driver.find_element_by_id('myid')
print(element.value_of_css_property('background-color'))

value_of_css_property() documentation.

Sign up to request clarification or add additional context in comments.

1 Comment

Is it still the case as of today? can't BeautifulSoup do that yet?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.