我在网站上做过网页抓取。它只在页面中取得前20个元素。如果我们向下滚动,其余元素将被加载。如何刮这些元素呢?有没有什么不同的方法来做到这一点?BeautifulSoup仅识别页面中的几个元素
import requests
from bs4 import BeautifulSoup
r=requests.get("https://www.century21.com/real-estate/rock-spring-ga/LCGAROCKSPRING/")
c=r.content
c
soup=BeautifulSoup(c,"html5lib")
soup
all=soup.find_all("div",{"class":"property-card-primary-info"})
len(all)
它只给出20个。不是全部。如何刮掉隐藏的元素呢?
元素似乎滚动动作之后被加载,则可能需要另一种工具来提取它们。 – PRMoureu
什么样的工具? –
selenium可以工作,https://stackoverflow.com/questions/14583560/selenium-retrieve-data-that-loads-while-scrolling-down – PRMoureu