Redfinのウェブサイトでいくつかの写真をクロールしたいのですが、FindAll()メソッドが親クラスがImageCardの画像URLをすべて見つけることができないようです。Beautifulsoup findall()がすべてのターゲットを見つけることができません
from bs4 import BeautifulSoup
import urllib2
def make_soup(url):
headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
req = urllib2.Request(url, headers=headers)
thepage = urllib2.urlopen(req).read()
soupdata = BeautifulSoup(thepage, "html.parser")
return soupdata
soup = make_soup("https://www.redfin.com/CA/San-Diego/5747-Adobe-Falls-Rd-92120/unit-A/home/5437025")
imgcards = soup.findAll('div', {'class': 'ImageCard'})
for imgcard in imgcards:
img = imgcard.findAll('img')
print(img['src'])
I want to download all the images in this slide on the web page
要素ツリーは次のとおりです: elements tree of webpage
私はスライドの最初の画像のdiv要素を見つけることができます
は、ここでは、コードです。誰かがそれを理解できることを願っています!ありがとう!!
sidenote: 'findAll()'の代わりに 'find_all()'を使用してください:https://www.crummy.com/software/BeautifulSoup/bs4/doc/#method-names –