[Python] Web scraping in python [closed]

Discussão em 'Python' iniciado por Stack, Maio 21, 2025.

  1. Stack

    Stack Membro Participativo

    I want to scrap all pages with trip offers and I could not find a way to get this info. Here is my code:

    URLS = {
    "ITAKA": "https://www.itaka.pl/last-minute/?participants%5B0%5D%5Badults%5D=2&page=1",
    "Rainbow": "https://r.pl/last-minute?typTransportu=AIR&data&dorosli=1995-01-01&dorosli=1995-01-01&dzieci=nie&liczbaPokoi=1&dowolnaLiczbaPokoi=nie&dataWylotu&dlugoscPobytu=*-*&dlugoscPobytu.od=&dlugoscPobytu.do=&cena=avg&cena.od=&cena.do=&ocenaKlientow=*-*&promocja=last-minute&hotelUrl&produktUrl&sortowanie=termin-asc&strona=1"
    }
    response = requests.get(URLS["Rainbow"])
    soup = BeautifulSoup(response.content, "html.parser")
    data = []
    page_number = soup.find("a", class_="r-button r-button--primary r-button--hover r-button--text r-button--only-text r-button--svg-margin-left r-pagination__page-btn").get_text(strip="True")
    print(page_number)
    response = requests.get(URLS["ITAKA"])
    soup = BeautifulSoup(response.content, "html.parser")
    data = []
    spans = soup.find_all("div", class_="d-flex align-items-center justify-content-center position-relative styles_c__DPfx9")
    if span in spans:
    number = span.find("span", style_="").get_text(strip=True)
    print(number)
    else:
    print("Span with the number not found.")

    Continue reading...

Compartilhe esta Página