Step-by-step tutorials for you to get started with web scraping

Download Octoparse

Scrape product information from Amazon

Tuesday, November 06, 2018

In this tutorial, we are going to show you how to scrape the product information from Amazon.com.

To follow through, you may want to use this URL in the tutorial:

https://www.amazon.com/s?rh=i%3Aelectronics%2Cn%3A172541%2Cp_n_feature_four_browse-bin%3A12097501011&ie=UTF8&lo=electronics

We will enter each detail page of Bluetooth Headphones and scrape the details including the product title, brand, rating, and price.

This tutorial will also cover:

   · Deal with AJAX for pagination

 

Here are the main steps in this tutorial:  [Download task file here ]

1) "Go To Web Page" - to open the targeted web page

2) Create a pagination loop - to scrape all the results from multiple pages

3) Create a "Loop Item" - to loop click into each item on each list

4) Extract data - to select the data for extraction

5) Start extraction - to run the task and get data

 

 

 

1) "Go To Web Page" - to open the targeted web page

   · Click "+ Task" to start a new task with Advanced Mode

     Advanced Mode is a highly flexible and powerful web scraping mode. For people who want to scrape from websites with complex structures, like Walmart.com, we strongly recommend Advanced Mode to start your data extraction project.

   · Paste the URL into the "Extraction URL" box and click "Save URL" to move on

   · Turn on the “Workflow Mode” by switching the "Workflow" button in the top-right corner in Octoparse

     We strongly suggest you turn on the "Workflow Mode" to get a better picture of what you are doing with your task, just in case you mess up with the steps.

 

 

 

 

2) Create a pagination loop - to scrape all the results from multiple pages

   · Click "Next" button

   · Click "Loop click next page" on "Action Tips"

   · Set up AJAX Load for the "Click to paginate" action

     Amazon.com applies the AJAX technique to the pagination button. Therefore, we need to set up AJAX Load for the "Click to paginate" action.

     · Uncheck the box for "Retry when page remains unchanged (use discreetly for AJAX loading)"

     · Check the box for "Load the page with AJAX" and set up AJAX Timeout as 10 seconds

     · Click "OK" to save

 

 

 

3) Create a "Loop Item" - to scrape all the items on each page

   · Click "Go To Web Page" to go back to the first page

     When extracting data throughout multiple pages, you should always begin your task building on the first page.

 

   · Click the name of the first product on the current page

   · Click "Select all" on the "Action Tips" panel

     Octoparse will automatically select all the links to the detail pages on the current page. The selected links will be highlighted in green while other links to the detail pages will be highlighted in red.

   · Click "Loop click each element" to create a "Loop Item"

     Octoparse will click through each link captured in the "Loop Item", and open the detail page.

Tips!

If you want to learn more about AJAX, here is a related tutorial you might need:

· Deal with AJAX 

 

 

 

4) Extract data - to select the data for extraction  

After you click "Loop click each element", Octoparse will open the detail page of the first hotel.

   · Click on the data you need on the page

   · Select "Extract text of the selected element" from the "Action Tips"

   · Rename the fields by selecting from the pre-defined list or inputting on your own

Tips!

When the content of the page has already shown out, but it is still loading, you could click the "X" button at the right end of the navigating bar to stop loading.

 

 

 

 5) Save and start extraction - to run the task and get data 

    · Click “Start Extraction” on the upper left side

    · Select “Local Extraction” to run the task on your computer, or select “Cloud Extraction” to run the task in the Cloud (for premium users only)

 

Here is the sample output. You can see some blank fields in the column "Price".  This is because these products are out of stock and thus they don't have the price information. 

 

Tips!

By default, if Octoparse cannot find the element of the defined pattern on the page, the field will be left blank. However, Octoparse may fail to find the element of the defined pattern even if the element needed is shown on the website. If you encounter this problem, here are a related tutorial you might need:

· What to do with those blank fields I got in the extracted result? 

 

Happy data hunting!

 

Was this article helpful? Contact us  at any time if you need our help!

Download Octoparse to start web scraping or contact us for any
question about web scraping!

Contact us Download
btn_sidebar_use.png
btn_sidebar_form.png