[Python] for what purpose we use time module in scraping with BeautifulSoup libraries python

Discussão em 'Python' iniciado por Stack, Junho 30, 2025.

  1. Stack

    Stack Membro Participativo

    I've been facing an issue where the code I'm working with is functioning properly on some websites, but not on others. I'm not sure why this is happening, and I'm seeking help from anyone who may have experience with similar issues or expertise in the specific programming languages and systems involved. Any insights or solutions would be greatly appreciated.

    from selenium import webdriver
    from bs4 import BeautifulSoup

    url = 'https://www.onthemarket.com/for-sale/property/uk/'


    options = webdriver.ChromeOptions()
    options.add_argument('headless')
    driver = webdriver.Chrome(options=options)

    driver.get(url)

    driver.implicitly_wait(10)

    html_content = driver.page_source

    driver.quit()

    soup = BeautifulSoup(html_content, 'html.parser')

    property_cards = soup.find_all('li', class_='otm-PropertyCard isOwu')

    for property in property_cards:
    title = property.find('span', class_="title")
    location = property.find('span', class_="address")
    price = property.find('div', class_="otm-Price")
    Extrainfo = property.find('li', class_="otm-ListItemOtmBullet before:bg-brand-contrast")
    #more = property.find('div', class_="otm-PropertyCardInfo")

    print(f'title: {title.text}')
    print(f'location: {location.text}')
    print(f'price: {price.text}')
    print(f'Extrainfo: {Extrainfo.text}')
    #print(f'more: {more.text}')
    print()

    Continue reading...

Compartilhe esta Página