Matching Attribute Values in CSS Selectors

I had a situation where I was doing some web scraping, and the site, while it had a predictable structure, had some unpredictable class names for the elements I was searching for.

In all cases, there was a class that began something like "ItemOfInterest_image_item__", but where the suffix would vary such that I couldn't depend on it matching from request to request.

So, today I learned that you can match an attribute value in a variety of ways:

// Match at the start of the attribute declaration
div[class^=ItemOfInterest_image_item__] img {}
// Match at the end of the attribute declaration
div[class$=ItemOfInterest_image_item__] img {}
// Match anywhere in the attribute declaration
div[class*=ItemOfInterest_image_item__] img {}

In my case, the specific class name could appear anywhere in the string, so I used the * selector.