I have a line of code in a python script as shown below
for summaries in soup.findAll('div',{'class':'cb-lv-scrs-col cb-font-12 cb-text-complete'}):
#do something with summaries
However, i want summaries to also include items from div items with another class called cb-scag-mtch-status cb-text-inprogress
for summaries in soup.findAll('div',{'class':['cb-lv-scrs-col cb-font-12 cb-text-complete','cb-scag-mtch-status cb-text-inprogress']}):
#do something with summaries
but this is not working. What is the problem and how do i fix it?
解决方案
I would make a simple CSS selector:
soup.select('div[class="cb-lv-scrs-col cb-font-12 cb-text-complete"],div[class="cb-scag-mtch-status cb-text-inprogress"]')
but, I doubt you really need or should check all of the classes present on an element, would not that be sufficient:
soup.select('div.cb-text-complete,div.cb-text-inprogress')