The CSS Wildcard
You can use the wildcard *
in CSS Locators too! In fact, we can use it in a similar way, when we want to ignore the tag type. For example:
- The CSS Locator string
'*'
selects all elements in the HTML document. - The CSS Locator string
'*.class-1'
selects all elements which belong toclass-1
, but this is unnecessary since the string'.class-1'
will also do the same job. - The CSS Locator string
'*#uid'
selects the element withid
attribute equal touid
, but this is unnecessary since the string'#uid'
will also do the same job.
In this exercise, we want you to work by analogy with the wildcard character you know from XPath notation to discover how to select all the children of a certain element in CSS Locator notation.
This exercise is part of the course
Web Scraping in Python
Exercise instructions
- Assign to the variable
css_locator
a CSS Locator string which will select all children (regardless of tag-type) of the unique element in the HTML document that has itsid
attribute equal touid
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create the CSS Locator to all children of the element whose id is uid
css_locator = ____