amazondata


Nameamazondata JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/AnupKumarPanwar/amazondata
SummaryA python package to get amazon product and search data in json form. The package does not require any API keys as it works by scraping the amazon page.
upload_time2023-11-09 13:30:51
maintainer
docs_urlNone
authorAnup Kumar Panwar
requires_python
licenseMIT
keywords amazon scraper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # amazondata

[![PyPI version](https://badge.fury.io/py/amazondata.svg)](https://badge.fury.io/py/amazondata)

A python package to get amazon product and search data in json form. The package does not require any API keys as it works by scraping the amazon page.

Reference: [How To Scrape Amazon Product Details and Pricing using Python](https://medium.com/scrapehero/tutorial-how-to-scrape-amazon-product-details-using-python-56d40e7503b7)

## Install

```
pip install amazondata
```

## Usage

To get Amazon product details from the url, use the following function.

### get_product_from_url(url)

```python
from amazondata.product_details_extractor import ProductDetailsExtractor

product_details_extractor = ProductDetailsExtractor()

data = product_details_extractor.get_product_from_url('https://www.amazon.in/dp/B09JSYVNZ2')

print(data)
```

To get Amazon product details from the ASIN (Amazon Standard Identification Number) code, use the following function.

### get_product_from_asin_code(asin_code)

```python
from amazondata.product_details_extractor import ProductDetailsExtractor

product_details_extractor = ProductDetailsExtractor()

data = product_details_extractor.get_product_from_asin_code('B09JSYVNZ2')

print(data)
```

To get the list of products from search query use the following function

### search(query, page)

```python
from amazondata.search_result_extractor import SearchResultExtractor

search_result_extractor = SearchResultExtractor()

data = search_result_extractor.search('perfume for men', 3)

print(data)

```

NOTE: Optionally, you can pass custom `headers` to all these functions. The default headers value is:

```python
headers = {
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
            "Sec-Fetch-Site": "none",
            "Host": "www.amazon.in",
            "Accept-Language": "en-IN,en-GB;q=0.9,en;q=0.8",
            "Sec-Fetch-Mode": "navigate",
            "Accept-Encoding": "gzip, deflate, br",
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15",
            "Connection": "keep-alive",
            "Upgrade-Insecure-Requests": "1",
            "Sec-Fetch-Dest": "document",
            "Priority": "u=0, i",
        }
```

In case the the scraper gets blocked from Amazon, you can fetch the html code using selenium and pass the html code to the following function

```python
data = extract_search_results(html_code)
```

```python
data = extract_product_details(html_code)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AnupKumarPanwar/amazondata",
    "name": "amazondata",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Amazon,Scraper",
    "author": "Anup Kumar Panwar",
    "author_email": "1anuppanwar@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/75/0c/67f3b76324d6ab07cb3dd023fe60e99044761ae491caa9ed0de2fb5fef61/amazondata-0.1.3.tar.gz",
    "platform": null,
    "description": "# amazondata\n\n[![PyPI version](https://badge.fury.io/py/amazondata.svg)](https://badge.fury.io/py/amazondata)\n\nA python package to get amazon product and search data in json form. The package does not require any API keys as it works by scraping the amazon page.\n\nReference: [How To Scrape Amazon Product Details and Pricing using Python](https://medium.com/scrapehero/tutorial-how-to-scrape-amazon-product-details-using-python-56d40e7503b7)\n\n## Install\n\n```\npip install amazondata\n```\n\n## Usage\n\nTo get Amazon product details from the url, use the following function.\n\n### get_product_from_url(url)\n\n```python\nfrom amazondata.product_details_extractor import ProductDetailsExtractor\n\nproduct_details_extractor = ProductDetailsExtractor()\n\ndata = product_details_extractor.get_product_from_url('https://www.amazon.in/dp/B09JSYVNZ2')\n\nprint(data)\n```\n\nTo get Amazon product details from the ASIN (Amazon Standard Identification Number) code, use the following function.\n\n### get_product_from_asin_code(asin_code)\n\n```python\nfrom amazondata.product_details_extractor import ProductDetailsExtractor\n\nproduct_details_extractor = ProductDetailsExtractor()\n\ndata = product_details_extractor.get_product_from_asin_code('B09JSYVNZ2')\n\nprint(data)\n```\n\nTo get the list of products from search query use the following function\n\n### search(query, page)\n\n```python\nfrom amazondata.search_result_extractor import SearchResultExtractor\n\nsearch_result_extractor = SearchResultExtractor()\n\ndata = search_result_extractor.search('perfume for men', 3)\n\nprint(data)\n\n```\n\nNOTE: Optionally, you can pass custom `headers` to all these functions. The default headers value is:\n\n```python\nheaders = {\n            \"Accept\": \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n            \"Sec-Fetch-Site\": \"none\",\n            \"Host\": \"www.amazon.in\",\n            \"Accept-Language\": \"en-IN,en-GB;q=0.9,en;q=0.8\",\n            \"Sec-Fetch-Mode\": \"navigate\",\n            \"Accept-Encoding\": \"gzip, deflate, br\",\n            \"User-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15\",\n            \"Connection\": \"keep-alive\",\n            \"Upgrade-Insecure-Requests\": \"1\",\n            \"Sec-Fetch-Dest\": \"document\",\n            \"Priority\": \"u=0, i\",\n        }\n```\n\nIn case the the scraper gets blocked from Amazon, you can fetch the html code using selenium and pass the html code to the following function\n\n```python\ndata = extract_search_results(html_code)\n```\n\n```python\ndata = extract_product_details(html_code)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python package to get amazon product and search data in json form. The package does not require any API keys as it works by scraping the amazon page.",
    "version": "0.1.3",
    "project_urls": {
        "Download": "https://pypi.org/project/amazondata/",
        "Homepage": "https://github.com/AnupKumarPanwar/amazondata"
    },
    "split_keywords": [
        "amazon",
        "scraper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67ab6375c5039dc28faf5d47bbec58ab618b977c6636b558c2072776150ce441",
                "md5": "7557a08cf1735cb00f5598f04cb0441a",
                "sha256": "7d178b2d004a8df975a01d649795541b527b78f839c146bec1488c65310313bf"
            },
            "downloads": -1,
            "filename": "amazondata-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7557a08cf1735cb00f5598f04cb0441a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7291,
            "upload_time": "2023-11-09T13:30:49",
            "upload_time_iso_8601": "2023-11-09T13:30:49.891544Z",
            "url": "https://files.pythonhosted.org/packages/67/ab/6375c5039dc28faf5d47bbec58ab618b977c6636b558c2072776150ce441/amazondata-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "750c67f3b76324d6ab07cb3dd023fe60e99044761ae491caa9ed0de2fb5fef61",
                "md5": "3d0dbc7704c586a234a54401db1ced17",
                "sha256": "3a2f944715bf9f3dc1bc611b56490365c654c95db881f583bc62e5707af56936"
            },
            "downloads": -1,
            "filename": "amazondata-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "3d0dbc7704c586a234a54401db1ced17",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5889,
            "upload_time": "2023-11-09T13:30:51",
            "upload_time_iso_8601": "2023-11-09T13:30:51.557072Z",
            "url": "https://files.pythonhosted.org/packages/75/0c/67f3b76324d6ab07cb3dd023fe60e99044761ae491caa9ed0de2fb5fef61/amazondata-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-09 13:30:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AnupKumarPanwar",
    "github_project": "amazondata",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "amazondata"
}
        
Elapsed time: 0.51313s