dimanche 6 décembre 2020

Web scraping throught multiple pages doesnt save each result -beautifulsoup

Cant seem to find answer, it loops throught pages, but it doesnt write anything into my list. Im just learning and trying my best, would appreciate some help. At the end I print the len of title and its still 0.

from bs4 import BeautifulSoup
import requests


for page in range(20, 200, 20):
    current_page = 'https://auto.bazos.sk/{}/?hledat=kolesa&hlokalita=&humkreis=&cen'.format(page)
    web_req = requests.get(current_page).text
    soup = BeautifulSoup(requests.get(current_page).content, 'html.parser')

    title_data = soup.select('.nadpis')
    title = []
    for each_title in title_data:
        title.append(each_title.text)
    print(current_page)

print(len(title))

Aucun commentaire:

Enregistrer un commentaire