Giter Site home page Giter Site logo

prakashbabuyrtr / amazonscraper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krpintu/amazonscraper

0.0 0.0 0.0 20 KB

This package allows you to search for products on Amazon and extract some useful information (ratings, number of comments).

License: GNU General Public License v3.0

Python 100.00%

amazonscraper's Introduction

Amazon Review Scraper

This is a simple python library that scrapes reviews from amazon.com and writes it into a csv file.

Usage

  1. Instantiating the object: scraper = AmazonReviewScraper.AmazonReviewScraper(url, start_page=1, end_page=None, sleeping_time=0, file_name="fetchfile.csv")

    • url: In the product's page, scroll down to the end of the reviews and click see all reviews. Click on that and copy the url. This url is your first parameter. Example: https://www.amazon.in/Samsung-Galaxy-J4-Blue-Offer/dp/B07DG9384L/ref=sr_1_4?ie=UTF8&qid=1551862000&sr=8-4&keywords=samsung+j7+prime

    • start page: This is the second parameter. Mention the page from which you want to scrape.

    • end page: This is the third parameter. Mention at what page the scraper has to stop scraping and by Default value is None.

    • sleeping_time(in seconds): This is the 4th argument. Amazon might block your IP if it receives too many requests every second. To prevent that, you can mention sleeping_time (in seconds). The scraper will wait anywhere from 0 to the sleeping_time before scraping every page. If you don't want to wait before scraping every page, give the value as 0.

    • file_name: This is the 5th argument. Here we provide the name of the file in which we can save file scrape data. By default file name is fetchfile.csv.Here you have to provide .csv extension.

  2. Call the scrape(self, return_value=False) method: scraper.scrape().to perform scrape of the website. there is 1 parameter in this function that is return value. if we pass True as parameter then it will directly return the scrape value to 'scraper' object.

  3. Write to CSV using write_csv() method: scraper.write_csv() to write csv. As by default it automatic save the csv file as 'fetchfile.csv'

Example Code

from AmazonReviewScraper import AmazonReviewScraper

url = input("Enter URL: ")
start_page = input("Enter Start Page Number: ")
end_page = input("Enter End Page Number: ")
sleeping_time = input("Enter sleeping time rangein second: ")
file_name = "samsungj7.csv"

scraper = amazon_review_scraper.amazon_review_scraper(url, start_page, end_page, sleeping_time,file_name)
scraper.scrape()

amazonscraper's People

Contributors

krpintu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.