Using Beautiful Soup to find specific class

后端 未结 3 642

I am trying to use Beautiful Soup to scrape housing price data from Zillow.

I get the web page by property id, eg. http://www.zillow.com/homes/for_sale/18429834_zpid/

3条回答
  •  广开言路
    2021-02-02 03:32

    import requests
    from bs4 import BeautifulSoup
    
    zpid = "18429834"
    url = "http://www.zillow.com/homes/" + zpid + "_zpid/"
    
    r = requests.get(url)
    
    soup = BeautifulSoup(r.content, "lxml")
    
    g_data = soup.find_all("div", {"class": "home-summary-row"})
    
    print g_data[1].text
    
    #for item in g_data:
    #        print item("span")[0].text
    #        print '\n'
    

    I got this working too -- but it looks like someone beat me to it.

    going to post anyways.

提交回复
热议问题