【问题标题】:how to scrape page inside the result card using BeatifulSoup?如何使用 BeautifulSoup 抓取结果卡内的页面?
【发布时间】:2022-01-18 07:20:19
【问题描述】:
                    <a href="https://magicpin.in/New-Delhi/Laxmi-Nagar/Restaurant/Bangalore-Ki-Famous-Biriyani/store/317630/?utm_source=search" data-type="around-merchant-card" onclick="sendEvent('web_searchlandingpage', 'click_search_merchant_card');">
                        <div class="merchant-logo-holder lazyloaded" data-bg="https://lh3.googleusercontent.com/UE8HJOOmV0hZsCbxbwQyha8UNa2ETY3-3zExps_mxUi-nbxVkgEBXo0kxghMHOUp87pge5tqIGrsU9Pu-iJ3h0_IETE=w64" style="background-image: url(&quot;https://lh3.googleusercontent.com/UE8HJOOmV0hZsCbxbwQyha8UNa2ETY3-3zExps_mxUi-nbxVkgEBXo0kxghMHOUp87pge5tqIGrsU9Pu-iJ3h0_IETE=w64&quot;);" title=", Laxmi Nagar, New Delhi"></div>
                    </a>
                    <div class="merchant-name-address">
                        <a href="https://magicpin.in/New-Delhi/Laxmi-Nagar/Restaurant/Bangalore-Ki-Famous-Biriyani/store/317630/?utm_source=search" data-type="around-merchant-card" onclick="sendEvent('web_searchlandingpage', 'click_search_merchant_card');">
                            <h3 class="merchant-name">
                                Bangalore Ki Famous Biriyani
                                
                            </h3>
                            <h4 class="merchant-location">
                                Laxmi Nagar
                                ,  New Delhi 
                            </h4>
                        </a>
                        <!-- 
                        <a href="" data-type="merchant_card_links" data-target="subcategory">
                            <h5 class="subcategory-tag"> </h5>
                        </a>
                         -->
                    </div>

                        
                        <div class="rating" style="background-color: #8bcc00; border-color: #8bcc00;">
                            <img src="https://static.magicpin.com/samara/static/images/merchant/star-white.svg" class="star" onerror="this.onerror=null;this.alt='';recordBrokenImages(this,false,4);">
                            <span class="rating-value">3.7</span>
                        </div>
                        
                    
                    
                    <section class="merchant-details">
                        <div class="cft-timing">
                            
                            <article class="detail-heading cft-heading">Average Spent: </article>
                            <span class="detail-value">₹500</span>
                            
                        </div>

                        <div class="merchant-attributes">
                            <div class="cover-holder">
                                <a href="https://magicpin.in/New-Delhi/Laxmi-Nagar/Restaurant/Bangalore-Ki-Famous-Biriyani/store/317630/?utm_source=search" data-type="around-merchant-card" onclick="sendEvent('web_searchlandingpage', 'click_search_merchant_card');">
                                    <div class="merchant-cover lazyloaded" data-bg="https://lh3.googleusercontent.com/W70wpIcovlvssmLSpcyub4RjHABennVNRWxznclaxD7PEcZhdJrgygOwn5qJ3XrlYq9Yv90k-w2Ld0lTfaylBxIGmw=w512" style="background-image: url(&quot;https://lh3.googleusercontent.com/W70wpIcovlvssmLSpcyub4RjHABennVNRWxznclaxD7PEcZhdJrgygOwn5qJ3XrlYq9Yv90k-w2Ld0lTfaylBxIGmw=w512&quot;);" title=", Laxmi Nagar, New Delhi">
                                        
                                    </div>
                                </a>
                            </div>
                            <div class="details">
                                
                                
                                <article class="detail-heading">Highlights: </article>
                                <span class="detail-value"> 
                                
                                    <span class="comma-separator">
                                        Magic Weekend 14 16
                                    </span>
                                
                                    <span class="comma-separator">
                                        Mw 20200123
                                    </span>
                                
                                </span>
                                
                            </div>
                        </div>

                        
                    </section>
                    
                    <div class="merchant-card-actions">
                        
                        <div class="action claim-deal-button-react show-mb" data-sku="food_1158872_other" data-merchantname="Bangalore Ki Famous Biriyani" data-dealid="1164110">
                            <p class="cashback">
                                CASHBACK<span>upto 10.0% OFF</span>
                            </p>
                        </div>
                        <a class="cashback hide-mb action" target="_blank" href="https://magicpin.in/deal/?dealId=1164110&amp;userId=5290338">
                            CASHBACK<span>upto 10.0% OFF</span>
                        </a>  
                        

                        

                        
                        
                    </div>
                </div> 

页面网址 - https://magicpin.in/Delhi/search/?dist=10&query=biriyani&rt=3

此页面现在包含一些餐厅卡,同时在循环中报废页面我想进入餐厅卡并刮掉编号。里面的评论,我不知道怎么做我用这段代码来抓取首页

import requests
from bs4 import BeautifulSoup
import pandas as pd

url = "https://magicpin.in/Delhi/search/?dist=10&query=biriyani&rt=3"  # URL of the website 
header = {'User-Agent':'Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36'} # Temporary user agent
r = requests.get(url, headers=header)
soup = BeautifulSoup(r.content, 'html.parser')

divs = soup.find_all('div', class_ ="merchant-card-single")
for item in divs:
    title = item.find('h3').text.strip() # restaurant name
    loc = item.find('h4', class_ ="merchant-location").text.strip() # restaurant location
    try: # used this try and except method because some restaurants are unrated and while scrpaping those we would run into an error
        rating = item.find('div', class_="rating").text 
        
        
    except:
        rating = None

    pricce = item.find('div', class_="cft-timing").text.strip() # price for biriyani
    
    biry_del = {
        'name': title,
        'location': loc,
        'rating': rating,
        'price': price
    }
    rest_list.append(biry_del)

希望大家理解,如有困惑请在评论中提问。

【问题讨论】:

  • 感谢您展示 HTML 片段。您能否也展示您遇到问题的 Python 代码?
  • 我已经添加了,请检查。

标签: python web-scraping beautifulsoup


【解决方案1】:

注意: 您问题中的代码无效,变量未定义或有拼写错误且没有预期结果 - 所以这只是正确方向的提示

会发生什么?

看看你的汤,没有包含评级的&lt;div&gt;

如何解决?

选择更具体 - 评级存储在 &lt;span&gt; 中,类为 rating-value

rating = item.find('span', class_="rating-value").text

编辑

根据您的评论,您想切换到详细信息并在那里执行操作 - 只需从 &lt;a&gt; 获取 url 并执行另一个请求:

url = item.find('a').get('href')
detailsSoup = BeautifulSoup(requests.get(url).text)
### look into your detailsSoup to find what you are searching for ...

要获取raiting详细信息,最好使用现有的api - 从url中提取merchands id并获取json数据:

url = item.find('a').get('href')
mid = url.split('/')[-2]
ratings = requests.get(f'https://magicpin.in/sam-api/merchants/get_merchant_reviews/?merchantUserId={mid}').json()['data']

示例

import requests
from bs4 import BeautifulSoup
import pandas as pd

url = "https://magicpin.in/Delhi/search/?dist=10&query=biriyani&rt=3"  # URL of the website 
header = {'User-Agent':'Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36'} # Temporary user agent
r = requests.get(url, headers=header)
soup = BeautifulSoup(r.content, 'html.parser')
rest_list=[]

divs = soup.find_all('div', class_ ="merchant-card-single")

for item in divs:
    title = item.find('h3').text.strip() # restaurant name
    loc = item.find('h4', class_ ="merchant-location").text.strip() # restaurant location
    try: # used this try and except method because some restaurants are unrated and while scrpaping those we would run into an error
        rating = item.find('span', class_="rating-value").text 
        
        
    except:
        rating = None

    price = item.find('div', class_="cft-timing").text.strip() # price for biriyani

    url = item.find('a').get('href')
    mid = url.split('/')[-2]
    ratings = requests.get(f'https://magicpin.in/sam-api/merchants/get_merchant_reviews/?merchantUserId={mid}').json()['data']

    biry_del = {
        'name': title,
        'location': loc,
        'rating': rating,
        'ratings': ratings,
        'price': price
    }
    rest_list.append(biry_del)

print(rest_list)

输出

[{'name': 'BBC, Best Biriyani & Chicken', 'location': 'Satyaniketan\n                                ,  New Delhi', 'rating': '4.4', 'ratings': [{'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2021-12-02T23:17:47+05:30', 'post_id': 945109867, 'review': '', 'user': {'name': 'Gulzar', 'vanity': '2 Followers', 'badge': None, 'total_visits': 13, 'total_spent': 17641, 'user_id': '10663391', 'description': '', 'deeplink': 'magicpin://profileuser?userId=10663391', 'profile_pic': 'https://lh3.googleusercontent.com/V-R22m0t7GAJGn-bOhzjWXywVWk-GgwT75aBGh5Bq3ZXku8npkIGbQaBCKgnkCwuDFXRlrmbOBhEOTNu3-tXRwjdJOqfw_D_7OSzqDk8=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2021-08-03T14:49:12+05:30', 'post_id': 940277857, 'review': '', 'user': {'name': 'Dattatray Aadhav', 'vanity': '31 Followers', 'badge': None, 'total_visits': 318, 'total_spent': 636061, 'user_id': '6194299', 'description': '', 'deeplink': 'magicpin://profileuser?userId=6194299', 'profile_pic': 'https://lh3.googleusercontent.com/5eA-UBjZ6PBwDD2Pgb15xREya5D9Mma4PEU2Ka4G9MDMR1qwNKGrJO5Z6FMT63SplMo_o8V7xWYTg_oMdh3PeiC1bXUr=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2021-08-03T14:46:52+05:30', 'post_id': 940277730, 'review': "Didn't like the promotions & discounts at this place", 'user': {'name': 'Anshika', 'vanity': '9 Followers', 'badge': None, 'total_visits': 56, 'total_spent': 28936, 'user_id': '9555088', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9555088', 'profile_pic': 'https://lh3.googleusercontent.com/YXgpyigxHNH0OMNnOsYerRxfmHAxxDYd9nsxzSveKwEAV8wrJUYmwabrgu0Ah_GMd7Mup26WjbWtPu-kkTcby6ddCoPQZ1aOCioi1wY6=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 2, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2021-08-03T14:48:56+05:30', 'post_id': 940277460, 'review': 'Loved the quality of products, safety precautions, variety of options, and location of store at this place', 'user': {'name': 'Priyank Jain', 'vanity': '118 Followers', 'badge': None, 'total_visits': 389, 'total_spent': 143081, 'user_id': '1140253', 'description': '', 'deeplink': 'magicpin://profileuser?userId=1140253', 'profile_pic': 'https://lh3.googleusercontent.com/nL4eRFh8Hi-b59CP4cL2cO57olZLxnL7yTiZ6xpoNLG67FQsGtEm-eTrKE9EaZ_cRtcR2TbldWxtqU2oG8Ob0x7Aag=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2021-08-03T14:46:56+05:30', 'post_id': 940277155, 'review': 'Loved the quality of products, safety precautions, variety of options, location of store, and promotions & discounts at this place', 'user': {'name': 'Naman', 'vanity': '5 Followers', 'badge': None, 'total_visits': 105, 'total_spent': 65821, 'user_id': '6148749', 'description': '19MaleChill', 'deeplink': 'magicpin://profileuser?userId=6148749', 'profile_pic': 'https://lh3.googleusercontent.com/C5UMTYVWkz1mNFUKWDfYKtCKDHoSUIrHsifJ7kfWrmJUBxjjyLW1lS0gOs4H31dekHdAXESRwN8cnqKVvxbY4P8GpRihVnZflujJfAjS=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2021-01-28T11:56:12+05:30', 'post_id': 932109603, 'review': 'Loved the range of products, delivery time, and promotions & discounts at this place', 'user': {'name': 'sunil', 'vanity': '', 'badge': None, 'total_visits': 2, 'total_spent': 586, 'user_id': '10156497', 'description': '', 'deeplink': 'magicpin://profileuser?userId=10156497', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-18T16:31:55+05:30', 'post_id': 929075104, 'review': '', 'user': {'name': 'Vrj', 'vanity': '', 'badge': None, 'total_visits': 11, 'total_spent': 34353, 'user_id': '7455242', 'description': '', 'deeplink': 'magicpin://profileuser?userId=7455242', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 4, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-18T16:32:42+05:30', 'post_id': 929074944, 'review': '', 'user': {'name': 'Vaibhav Deshatavar', 'vanity': '2 Followers', 'badge': None, 'total_visits': 26, 'total_spent': 7571, 'user_id': '4271349', 'description': '', 'deeplink': 'magicpin://profileuser?userId=4271349', 'profile_pic': 'https://lh3.googleusercontent.com/LbU80bZNxLLQ_bhc2VqWc6CJXHyqcNCLpBg5YBKMFWogWepbIyen3rdQIZx6WRZjT5l1OR63OLpZOuSVnz2TGXpP4pY=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': 'Niceeee ', 'review_date': '2020-12-18T12:38:07+05:30', 'post_id': 929056653, 'review': 'Loved the range of products, quality of products, delivery time, safe packaging, and promotions & discounts at this place', 'user': {'name': 'JAGGU RAJ', 'vanity': '', 'badge': None, 'total_visits': 3, 'total_spent': 3877, 'user_id': '9567167', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9567167', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-18T09:44:06+05:30', 'post_id': 929047869, 'review': '', 'user': {'name': 'Ramya', 'vanity': '', 'badge': None, 'total_visits': 40, 'total_spent': 307540, 'user_id': '7769558', 'description': '', 'deeplink': 'magicpin://profileuser?userId=7769558', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-18T09:43:13+05:30', 'post_id': 929047672, 'review': '', 'user': {'name': 'Hemraj', 'vanity': '', 'badge': None, 'total_visits': 9, 'total_spent': 7636, 'user_id': '9840082', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9840082', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-18T09:41:35+05:30', 'post_id': 929046779, 'review': 'Loved the quality of service, ambience, safety precautions, and taste at this place', 'user': {'name': 'Rahul', 'vanity': '1 Followers', 'badge': None, 'total_visits': 17, 'total_spent': 6594, 'user_id': '8723539', 'description': '', 'deeplink': 'magicpin://profileuser?userId=8723539', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-17T20:44:06+05:30', 'post_id': 929030684, 'review': 'Loved the quality of products and delivery time at this place', 'user': {'name': 'Mohit', 'vanity': '', 'badge': None, 'total_visits': 4, 'total_spent': 1086, 'user_id': '9878699', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9878699', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:12:24+05:30', 'post_id': 928845159, 'review': 'Loved the quality of products, safety precautions, variety of options, location of store, and promotions & discounts at this place', 'user': {'name': 'Vishal Sorap', 'vanity': '11 Followers', 'badge': None, 'total_visits': 39, 'total_spent': 44997, 'user_id': '2379680', 'description': '', 'deeplink': 'magicpin://profileuser?userId=2379680', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:06:28+05:30', 'post_id': 928844059, 'review': '', 'user': {'name': 'Harshal Rane', 'vanity': '58 Followers', 'badge': None, 'total_visits': 286, 'total_spent': 1263268, 'user_id': '1615250', 'description': '', 'deeplink': 'magicpin://profileuser?userId=1615250', 'profile_pic': 'https://lh3.googleusercontent.com/9eADr5gEJeWHS17inAcfrbke3k-aYBzm-3f6JoP2Kzkljf2sP6-fHE5hxbMw7EI7Hk3q8eZa-gGE1Zes_bXLNDcrpuc=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 3, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': 'Everything \n', 'review_date': '2020-12-14T22:12:22+05:30', 'post_id': 928843503, 'review': 'Loved the quality, service, safety precautions, and promotions at this place', 'user': {'name': 'Aman Bhagat', 'vanity': '28 Followers', 'badge': None, 'total_visits': 48, 'total_spent': 33812, 'user_id': '6589071', 'description': '', 'deeplink': 'magicpin://profileuser?userId=6589071', 'profile_pic': 'https://lh3.googleusercontent.com/jtEV_8v2CjIcrJTPLhL_me_flmHxOwrCesP6Z7J24Y-jvYWWfVvOjUcCCUZ2cvVD55wtUGtn9YupoqSuFyttXGaC6aw=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:08:00+05:30', 'post_id': 928842848, 'review': 'Loved the range of products, quality of products, and delivery time at this place', 'user': {'name': 'Ashok Kumar Baghel', 'vanity': '', 'badge': None, 'total_visits': 79, 'total_spent': 78554, 'user_id': '9374043', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9374043', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:05:44+05:30', 'post_id': 928841967, 'review': '', 'user': {'name': 'Akash dutt', 'vanity': '5 Followers', 'badge': None, 'total_visits': 196, 'total_spent': 711777, 'user_id': '7182223', 'description': '', 'deeplink': 'magicpin://profileuser?userId=7182223', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:07:11+05:30', 'post_id': 928841156, 'review': 'Loved the quality of service, ambience, safety precautions, taste, and price, promotions, & discounts at this place', 'user': {'name': 'Raunak', 'vanity': '44 Followers', 'badge': None, 'total_visits': 250, 'total_spent': 81010, 'user_id': '9210632', 'description': 'I am no one interesting', 'deeplink': 'magicpin://profileuser?userId=9210632', 'profile_pic': 'https://lh3.googleusercontent.com/-RVyHuI5_SABCC0LtLtV2oSCYmTyAJWJ-bv9ZX0lQY7tv6cdJIK0sW7BYTni2Pd6lv7Bb-Te1COJcQa9-2uWf3nkTcY=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T21:57:57+05:30', 'post_id': 928840295, 'review': 'Loved the variety of options, safety precautions, helpful staff, and price, promotions, & discounts at this place', 'user': {'name': 'Prashanth', 'vanity': '8 Followers', 'badge': None, 'total_visits': 75, 'total_spent': 374044, 'user_id': '9821253', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9821253', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:02:35+05:30', 'post_id': 928840224, 'review': 'Loved the range of products at this place', 'user': {'name': 'Sushant P', 'vanity': '39 Followers', 'badge': None, 'total_visits': 407, 'total_spent': 358857, 'user_id': '4789975', 'description': '', 'deeplink': 'magicpin://profileuser?userId=4789975', 'profile_pic': 'https://lh3.googleusercontent.com/_AWRlRrTsNUdZDKyB4mTeFK99T2gM29ScDGVt8j1C5NemAprx_gw3OofqS3_cm4cELfpWWzIie55YYHYHTpLEQ2rpqs=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 4, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': 'Amazon is best ', 'review_date': '2020-12-14T21:55:10+05:30', 'post_id': 928839174, 'review': 'Loved the delivery time and promotions & discounts at this place', 'user': {'name': 'Sunny', 'vanity': '6 Followers', 'badge': None, 'total_visits': 24, 'total_spent': 40934, 'user_id': '9768929', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9768929', 'profile_pic': 'https://lh3.googleusercontent.com/dDT5_ubc0MRR6y541WX6kGbqBBcm7xqeFxBPRUZgTO-x8hLF7fEzEkKzgwhq1r8wPDck-xtZCj99PyrO_i8xQgCA_-KyVV00kS31wBfS=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:01:07+05:30', 'post_id': 928838737, 'review': 'Loved the quality of service, ambience, and taste at this place', 'user': {'name': 'Sohil Merchant', 'vanity': '5 Followers', 'badge': None, 'total_visits': 199, 'total_spent': 98483, 'user_id': '9222147', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9222147', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T21:52:45+05:30', 'post_id': 928838145, 'review': '', 'user': {'name': 'pinki', 'vanity': '1 Followers', 'badge': None, 'total_visits': 7, 'total_spent': 3207, 'user_id': '9836153', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9836153', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:10:12+05:30', 'post_id': 928838005, 'review': '', 'user': {'name': 'Sudhanshu Shekhar', 'vanity': '3 Followers', 'badge': None, 'total_visits': 78, 'total_spent': 522579, 'user_id': '8217943', 'description': '', 'deeplink': 'magicpin://profileuser?userId=8217943', 'profile_pic': 'https://lh3.googleusercontent.com/PduS8X6YNq_gCRe_1sQ0zi6LFDalhGoeDeV_M7BJg_szWV7TLeqm2QotxNMczJDjLEQzJjTq7H3tAEtHLiDobBBguLBc=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 2, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:01:58+05:30', 'post_id': 928837918, 'review': 'Loved the ambience and taste at this place', 'user': {'name': 'Sandip Raul', 'vanity': '43 Followers', 'badge': None, 'total_visits': 87, 'total_spent': 257686, 'user_id': '3179212', 'description': '', 'deeplink': 'magicpin://profileuser?userId=3179212', 'profile_pic': 'https://lh3.googleusercontent.com/3nl1P7BGqdGiVdEGzjJ24SnV-aPDSe8KUv38d_kvo6G82NefqsVvlMN4l9AbDPhldMlWDN7JUgjzQvp9gKNFr9Sz1jt7K4nskEOIkXU=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T21:58:06+05:30', 'post_id': 928837904, 'review': 'Loved the quality of products, safety precautions, variety of options, location of store, and promotions & discounts at this place', 'user': {'name': 'Killer', 'vanity': '7 Followers', 'badge': None, 'total_visits': 28, 'total_spent': 21599, 'user_id': '7412507', 'description': '', 'deeplink': 'magicpin://profileuser?userId=7412507', 'profile_pic': 'https://lh3.googleusercontent.com/_fhBywD7kvez24utn17OhvtbYK-jMvnL9frdFLPxV_vJk2lILIkLE6FRxW58mfTZRBHNB0im-nSGE6GSzLJ3ULJMsgzC=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:05:34+05:30', 'post_id': 928837839, 'review': 'Loved the range of products, quality of products, delivery time, safe packaging, and promotions & discounts at this place', 'user': {'name': 'Axat', 'vanity': '', 'badge': None, 'total_visits': 26, 'total_spent': 22707, 'user_id': '9571962', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9571962', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T21:52:34+05:30', 'post_id': 928837057, 'review': '', 'user': {'name': 'Manna11', 'vanity': '', 'badge': None, 'total_visits': 3, 'total_spent': 1209, 'user_id': '9840078', 'description': '', 'deeplink': 'magicpin://profileuser?userId=9840078', 'profile_pic': '', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 4, 'reply_date': '0001-01-01T00:00:00Z'}, {'rating_text': 'Outlet Rating', 'reply': '', 'merchant': None, 'review_title': '', 'review_date': '2020-12-14T22:10:41+05:30', 'post_id': 928836452, 'review': 'Loved the range of products at this place', 'user': {'name': 'Rushikesh Ingale', 'vanity': '23 Followers', 'badge': None, 'total_visits': 116, 'total_spent': 217734, 'user_id': '6911448', 'description': '', 'deeplink': 'magicpin://profileuser?userId=6911448', 'profile_pic': 'https://lh3.googleusercontent.com/-fb2w-cH1_0rjjoK2GYQDYr1tu_SAF_NyLN7eUHvTATCwO9fP6QEaV_wd6blNamjhJ5radva3axs03SDO46HVhYosPI=s120', 'is_following': False}, 'media_list': [{'image_url': '', 'aspect_ratio': 1}], 'rating': 5, 'reply_date': '0001-01-01T00:00:00Z'}], 'price': 'Average Spent: \n₹350'}]

【讨论】:

  • 不不,实际上该 div 包含该跨度,因此我很想在报废评级时遇到问题,但我想在循环中进入该餐厅卡并报废。从里面的评级。希望你能理解。
  • 根据您的评论添加了一个编辑 - 只需在您的循环中执行第二个请求并获取餐厅详细信息。
猜你喜欢
  • 2019-06-03
  • 1970-01-01
  • 1970-01-01
  • 2019-10-27
  • 2015-06-07
  • 2015-05-08
  • 2016-09-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多