Selecting all elements that meet a criteria using selenium (python)
Question: Using selenium, is there a way to have the script pick out elements that meet
a certain criteria?

What I'm exactly trying to do is have selenium select all Twitch channels that
have more than X viewers. If you inspect element, you find this:

    
    
    <p class="info"
        562
        viewers on
        <a class="js-profile-link" href="/hey_jase/profile" 
        data-tt_content="live_channel" data-tt_content_index="1"
        data-tt_medium="twitch_directory" data-ember-action="1471">
        Hey_Jase
        </a>
    </p>
    


Answer: First of all, you can find all twitch channel links. Then, filter them based
on the view count.

Something along these lines:

    
    
    import re
    from selenium import webdriver
    
    
    THRESHOLD = 100  
    
    driver = webdriver.Firefox()
    driver.get("url")
    
    pattern = re.compile(r"(\d+)\s+viewers on")
    for link in driver.find_elements_by_css_selector("p.info a[data-tt_content=live_channel]"):
        text = link.find_element_by_xpath("..").text  # get to the p parent element
        match = pattern.search(text)  # extract viewers count
        if match:
            viewers_count = int(match.group(1))
            if viewers_count >= THRESHOLD:
                print(link.text, viewers_count)
    

