如何使用 Python 从 Lazada 抓取产品数据(产品名称、价格)?

问题描述 投票:0回答:1

我被告知要使用 Python 从 Lazada 网站上抓取产品数据(产品名称和价格)。但是,即使从互联网上搜索了所有解决方案后,我也不知道如何执行。有人可以帮我吗?

我在整个互联网和 Youtube 上都进行了搜索,但没有一个编码可以解决我的问题。

网址: https://www.lazada.com.my/guardian/?q=All-Products&from=wangpu&langFlag=zh&pageTypeId=2

我正在使用 MacBook Air M1。我只需要从所有 102 页的商店(由 url 给出)中提取所有产品名称和价格。

真希望有人能救救我。提前谢谢你。

python web-scraping e-commerce product data-analysis
1个回答
0
投票

我不会抓取整个平台,那太复杂了。相反,我会使用他们的 API。首先,您需要注册并获取您的 app_key 和 app_secret。然后你就可以使用自己的库与API调用

lazop_sdk
进行通信。详情这里 然后你可以从这个简单的 GET 请求开始

from lazop_sdk import LazopClient, LazopRequest

# Set up the Lazop client with your app key and secret
app_key = 'your_app_key'
app_secret = 'your_app_secret'
client = LazopClient(app_key, app_secret)

# Set up the Lazop request to retrieve all products
request = LazopRequest('/products/get', 'GET')
request.add_api_param('offset', 0)
request.add_api_param('limit', 100)

# Send the request and retrieve the response
response = client.execute(request)

# Print the list of products
products = response['data']['products']
for product in products:
    print(product)
© www.soinside.com 2019 - 2024. All rights reserved.