scrapy shell 'https://www.blibli.com/promosi/samsung-mobilephones-tablet?appsWebview=true'
fetch('https://www.blibli.com/promosi/samsung-mobilephones-tablet?appsWebview=true')
response.css('div.productset-carousel-mobile__block-item item')
[]
描述。我試圖獲取url中提到的產品的名稱和價格。 url中提到的產品的名稱和價格。因為要獲取div類的原始資料 = 'productset-carousel-mobile__block-item item'。 我正在寫 response.css('div.productset-carousel-mobile__block-item item') 但 每次它都給出空串列或轉到終端的下一行。
現在我不知道我哪里錯了。現在我正在學習Scrapy,從一個
現在我不知道我哪里錯了,現在我從一個youtube教程中學習scrapy。
所有的建議和鏈接都可以用來清除這個概念。 熱烈地接受。
uj5u.com熱心網友回復:
該網站的內容是動態的,所以你不能用xhr訪問它們。然而,有一個api可用,包含了你要找的同樣的東西。以下是你如何從登陸頁面上抓取產品名稱和它們所屬的類別。請隨意包括其他相關欄位。
import scrapy
class BliBliSpider(scrapy.Spider)。
name = 'blibli'/span>
start_urls = ['https://www.blibli.com/backend/content/promotions/samsung-mobilephones-tablet']
def parse(self, response)。
for item in response.json()['data'][' components'] 。
if not item['name']=='PRODUCT_CAROUSEL':continue。
for container in item['引數']。
cat_name = container['title']]
for product in container['products']。
yield {"category":cat_name,"product name":product['name']}.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/320241.html
標籤:
