При попытке спарсить заведения из Google Maps, beautifulsoup4 не может сарсить объект и выдет ему значение None

from bs4 import BeautifulSoup
import csv

CSV = 'result.csv'
HOST = 'https://www.google.com'
URL = 'https://www.google.com/maps/search/Canggu+villa/@-8.6419077,115.139734,14z'
HEADERS = {
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',

    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}

def get_html(url, params=None):
    r = requests.get(url, headers=HEADERS, params=params)
    return r

def get_content(html):
    soup = BeautifulSoup(html, 'html.parser')
    items = soup.find('div', class_='section-result-content')
    cards = []

    for item in items:
        cards.append(
                {
                'phone': item.find('span', class_='section-result-info section-result-phone-number').find_next_sibling('span').get_text(strip=True),
                'name': item.find('h3', class_='section-result-title').find('span').get_text(strip=True),
                'type': item.find('span', class_='section-result-details').get_text(strip=True)
                }
            )
    return cards

def save_doc(items, path):
    with open(path, 'w', newline=None,) as file:
        writer = csv.writer(file, delimiter=';')
        writer.writerow(['Phone number', 'Name', 'Type'])

        for item in items:
            writer.writerow([item['phone'], item['name'], item['type']])
def parser():
    PAGINATION = 2
    html = get_html(URL)
    if html.status_code == 200:
        cards = []

        for page in range(1, PAGINATION):
            print(f'page: {page}')
            html = get_html(URL, params={'page': page})
            cards.extend(get_content(html.text))
            save_doc(cards, CSV)
        print('Parsing is over')
    else:
        print('Error')

parser()

При выполнений выдает:

TypeError: 'NoneType' object is not iterable


Ответы (0 шт):