# amazon-scraper-python
[![Travis](https://img.shields.io/travis/tducret/amazon-scraper-python.svg)](https://travis-ci.org/tducret/amazon-scraper-python)
[![Coveralls github](https://img.shields.io/coveralls/github/tducret/amazon-scraper-python.svg)](https://coveralls.io/github/tducret/amazon-scraper-python)
[![PyPI](https://img.shields.io/pypi/v/amazonscraper.svg)](https://pypi.org/project/amazonscraper/)
[![Docker Build Status](https://img.shields.io/docker/build/thibdct/amazon2csv.svg)](https://hub.docker.com/r/thibdct/amazon2csv/)
![License](https://img.shields.io/github/license/tducret/amazon-scraper-python.svg)
# Description
This package allows you to search for products on [Amazon](https://www.amazon.com/) and extract some useful information (ratings, number of comments).
I wrote a French blog post about it [here](https://www.tducret.com/scraping/2018/06/05/amazon2csv-ou-comment-filtrer-les-produits-d-amazon-dans-excel.html)
# Requirements
- Python 3
- pip3
# Installation
```bash
pip3 install -U amazonscraper
```
# Command line tool `amazon2csv.py`
After the package installation, you can use the `amazon2csv.py` command in the terminal.
After passing a search request to the command (and an optional maximum number of products), it will return the results as csv :
```bash
amazon2csv.py --keywords="Python programming" --maxproductnb=2
```
```csv
Product title,Rating,Number of customer reviews,Product URL,Image URL,ASIN
"Python Crash Course: A Hands-On, Project-Based Introduction to Programming",4.5,370,https://www.amazon.com/Python-Crash-Course-Hands-Project-Based/dp/1593276036,https://images-na.ssl-images-amazon.com/images/I/51F48HFHq6L.jpg,1593276036
"A Smarter Way to Learn Python: Learn it faster. Remember it longer.",4.7,384,https://www.amazon.com/Smarter-Way-Learn-Python-Remember-ebook/dp/B077Z55G3B,https://images-na.ssl-images-amazon.com/images/I/51fNZfTUPXL.jpg,B077Z55G3
```
You can also pass a search url (if you added complex filters for example), and save it to a file :
```bash
amazon2csv.py --url="https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=python+scraping" > output.csv
```
You can then open it with your favorite spreadsheet editor (and play with the filters) :
![snapshot amazon2csv](snapshot_amazon2csv.png)
More info about the command in the help :
```bash
amazon2csv.py --help
```
# Using the `amazonscraper` Python package
```python
# -*- coding: utf-8 -*-
import amazonscraper
results = amazonscraper.search("Python programming", max_product_nb=2)
for result in results:
print("{}".format(result.title))
print(" - ASIN : {}".format(result.asin))
print(" - {} out of 5 stars, {} customer reviews".format(result.rating, result.review_nb))
print(" - {}".format(result.url))
print(" - Image : {}".format(result.img))
print()
print("Number of results : %d" % (len(results)))
```
Which will output :
```
Python Crash Course: A Hands-On, Project-Based Introduction to Programming
- ASIN : 1593276036
- 4.5 out of 5 stars, 370 customer reviews
- https://www.amazon.com/Python-Crash-Course-Hands-Project-Based/dp/1593276036
- Image : https://images-na.ssl-images-amazon.com/images/I/51F48HFHq6L.jpg
A Smarter Way to Learn Python: Learn it faster. Remember it longer.
- ASIN : B077Z55G3B
- 4.7 out of 5 stars, 384 customer reviews
- https://www.amazon.com/Smarter-Way-Learn-Python-Remember-ebook/dp/B077Z55G3B
- Image : https://images-na.ssl-images-amazon.com/images/I/51fNZfTUPXL.jpg
Number of results : 2
```
### Attributes of the `Product` object
Attribute name | Description
------------------- | ---------------------------------------
title | Product title
rating | Rating of the products (number between 0 and 5, False if missing)
review_nb | Number of customer reviews (False if missing)
url | Product URL
img | Image URL
asin | Product ASIN ([Amazon Standard Identification Number](https://fr.wikipedia.org/wiki/Amazon_Standard_Identification_Number))
--------------
# Docker
You can use the amazon2csv tool with the [Docker image](https://hub.docker.com/r/thibdct/amazon2csv/)
You may execute :
`docker run -it --rm thibdct/amazon2csv --keywords="Python programming" --maxproductnb=2`
## ð¤ The easy way ð¤
I also built a bash wrapper to execute the Docker container easily.
Install it with :
```bash
curl -s https://raw.githubusercontent.com/tducret/amazon-scraper-python/master/amazon2csv \
> /usr/local/bin/amazon2csv && chmod +x /usr/local/bin/amazon2csv
```
*You may replace `/usr/local/bin` with another folder that is in your $PATH*
Check that it works :
*On the first execution, the script will download the Docker image, so please be patient*
```bash
amazon2csv --help
amazon2csv --keywords="Python programming" --maxproductnb=2
```
You can upgrade the app with :
```bash
amazon2csv --upgrade
```
and even uninstall with :
```bash
amazon2csv --uninstall
```
## TODO
- [ ] If no product was found with the CSS selectors, it may be a new Amazon page style => change user agent and get the new page. Loop on all the user agents and check all the CSS selectors again
- [ ] Find a way to get the products without css selectors
没有合适的资源?快使用搜索试试~ 我知道了~
amazon-scraper-python:非官方客户端,以获取有关在亚马逊上出售的产品的一些信息
共17个文件
py:5个
html:1个
ini:1个
需积分: 9 3 下载量 88 浏览量
2021-02-28
02:43:31
上传
评论
收藏 141KB ZIP 举报
温馨提示
亚马逊刮板Python 描述 使用此软件包,您可以在上搜索产品并提取一些有用的信息(评分,评论数)。 我写了一篇法国博客文章 要求 的Python 3 点3 安装 pip3 install -U amazonscraper 命令行工具amazon2csv.py 安装软件包后,可以在终端中使用amazon2csv.py命令。 将搜索请求传递给命令(以及可选的最大产品数量)后,它将返回结果为csv: amazon2csv.py --keywords= " Python programming " --maxproductnb=2 Product title,Rating,Number of customer reviews,Product URL,Image URL,ASIN "Python Crash Course: A Hands-On, Project-Based Intro
资源详情
资源评论
资源推荐
收起资源包目录
amazon-scraper-python-master.zip (17个子文件)
amazon-scraper-python-master
MANIFEST.in 47B
.travis.yml 1KB
pytest.ini 56B
test
test_amazonscraper.py 3KB
not_satisfied.html 182B
Dockerfile 647B
LICENSE 1KB
amazon2csv.py 1KB
amazonscraper
client.py 15KB
__init__.py 3KB
amazon2csv 759B
setup.cfg 62B
snapshot_amazon2csv.png 127KB
requirements.txt 48B
setup.py 2KB
.gitignore 1KB
README.md 5KB
共 17 条
- 1
WillisWang
- 粉丝: 22
- 资源: 4701
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Javascript和Python的微商城项目设计源码 - MicroMall
- 基于Java的网上订餐系统设计源码 - online ordering system
- 基于Javascript的超级美眉网络资源管理应用模块设计源码
- 基于Typescript和PHP的编程知识储备库设计源码 - study-php
- Screenshot_2024-05-28-11-40-58-177_com.tencent.mm.jpg
- 基于Dart的Flutter小提琴调音器APP设计源码 - violinhelper
- 基于JavaScript和CSS的随寻订购网页设计源码 - web-order
- 基于MATLAB的声纹识别系统设计源码 - VoiceprintRecognition
- 基于Java的微服务插件集合设计源码 - wsy-plugins
- 基于Vue和微信小程序的监理日志系统设计源码 - supervisionLog
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1