У меня есть парсер 2гис, на сайте 2гиса есть теги которые хранят не пойми что.
Короче как пропустить none обьект в цикле, как это сделать?
код
## for div in divs:
##location = div.find('span', attrs={'class':'mediaMiniCard__address'})
##opening_hours = div.find('span', attrs={'class':'mediaMiniCard__opened_opened_tooltip_position_topLeft'})
## print(location)
## print(opening_hours)
import requests
from bs4 import BeautifulSoup as bs
headers1 = {'accept' : '*/*', 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}
bar_url = 'https://2gis.ru/kaluga/search/%D0%B1%D0%B0%D1%80?queryState=center%2F36.271892%2C54.523258%2Fzoom%2F11';
def g2isBar(bar_url, headers1):
organization = []
ses = requests.Session()
req = ses.get(bar_url, headers = headers1)
if req.status_code == 200:
souBar = bs(req.content, 'html.parser')
divs = souBar.find_all('div', attrs={'class':'online__panels'})
divscol = souBar.find_all('h2', attrs={'class':'searchBar__mediaTabText'})
divtitle = souBar.find_all('div', attrs={'class':'mediaMiniCard__body'})
for dive in divtitle:
nameCompany = dive.find('h3', attrs={'class':'mediaMiniCard__name'}).text
## nameCompanyLogo = dive.find('h3', attrs={'class' : 'mediaMiniCard__name._hasLogo'})
nameOrganizat = dive.find('h4', attrs ={'class':'mediaMiniCard__description'})
print(nameOrganizat)
print(nameCompany)
else:
print('error')
g2isBar(bar_url, headers1)