[英]Beautiful Soup find is returning empty value
我正在嘗試從該網站獲取餐館列表
https://www.352delivery.com/order/restaurants
到目前為止,我編寫了這個
import requests
from bs4 import BeautifulSoup
url = 'https://www.352delivery.com/order/restaurants'
response = requests.get(url,headers=headers)
soup = BeautifulSoup(response.text, "html.parser")
restaurant_wrapper = soup.find(class_ = "restaurant-card-info-wrapper")
print(restaurant_wrapper)
結果是“無”,我不知道為什么,我嘗試使用不同的名稱 class。我抓錯了 div 嗎?
我認為這里的問題是,你必須輸入一個有效的地址/街道,然后所有的餐廳都會被加載並顯示卡片。
可以查看此 url 以獲取餐廳:
https://www.352delivery.com/restaurants
import requests
from bs4 import BeautifulSoup
headers= {'User-Agent': 'Mozilla/5.0'}
url = 'https://www.352delivery.com/restaurants'
response = requests.get(url,headers=headers)
soup = BeautifulSoup(response.text, "html.parser")
restaurant_wrapper = soup.find_all(class_ = "restaurant-card-info-wrapper")
print(restaurant_wrapper)
[<div class="restaurant-card-info-wrapper">
<div class="restaurant-card-logo">
<img alt="Munecas Downtown Taco Garden" class="lazy" data-src="https://deliverlogic-common-assets.s3.amazonaws.com/editable/images/three52d/logos/front/55.jpg" height="52" title="Munecas Downtown Taco Garden" width="52"/>
</div>
<div class="restaurant-card-info">
<p class="restaurant-card-title">Munecas Downtown Taco Garden</p>
<p class="restaurant-card-cuisine">Indonesian, Locally Sourced, Mexican, Tex-Mex
</p>
<p class="restaurant-card-minimum"></p>
<p class=""></p>
</div>
</div>, <div class="restaurant-card-info-wrapper">
<div class="restaurant-card-logo">
<img alt="The Leaning Pig" class="lazy" data-src="https://deliverlogic-common-assets.s3.amazonaws.com/editable/images/three52d/logos/front/99.png" height="52" title="The Leaning Pig" width="52"/>
</div>
<div class="restaurant-card-info">
<p class="restaurant-card-title">The Leaning Pig</p>
<p class="restaurant-card-cuisine">Charcuteries, Deli, International, Subs/Sandwich
</p>
<p class="restaurant-card-minimum"></p>
<p class=""></p>
</div>
</div>,...]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.