I am trying to get statistics of a website. The 15 most recent drops. I want to be able to count the amount of drops that are of the milspec quality. I currently have code that counts how many of the 15 are blue but I want that number to keep going up everytime a new div that has the class of "item milspec" is added. Is there anyway to do this?
Here is my current code:
from time import sleep
from bs4 import BeautifulSoup
from selenium import webdriver
url = 'http://g2case.com/en'
browser = webdriver.Chrome()
browser.get(url)
def check_for_div_class_count(html, class_name):
soup = BeautifulSoup(html, 'html.parser')
milspecs = soup.findAll('div', {'class': class_name})
return len(milspecs)
for i in range(10):
print check_for_div_class_count(browser.page_source, 'item milspec')
sleep(2)
browser.close()