Beautiful Soup not waiting until page is fully loaded

后端 未结 2 2061
醉话见心
醉话见心 2021-01-07 14:52

So with my code below I want to open an apartment website URL and scrape the webpage. The only issue is that Beautiful Soup isn\'t waiting until the entire webpage is render

2条回答
  •  死守一世寂寞
    2021-01-07 15:07

    I'm happy with requests_html library. It will render Dynamic HTML for you. And is much simpler to implement than Selenium.

    from requests_html import HTMLSession
    import pyppdf.patch_pyppeteer
    from bs4 import BeautifulSoup
    
    url = 'https://xxxxx.com/properties/?sort=latest'
    
    session = HTMLSession()
    
    
    resp = session.get(link)
    resp.html.render()
    html = resp.html.html
    
    page_soup = BeautifulSoup(html, 'html.parser')
    
    containers = page_soup.find_all("div", {"class": "grid-item"})
    

提交回复
热议问题