When we scrape product information from e-commerce websites, more often than not, we expect to extract data not only from the search result page but also from each product's detail page. In this tutorial, we will teach you how to build a customized crawler to achieve that purpose.
Let's say we need to search for "camera lens" on eBay. See the sample URL below:
In this case, we want to extract the title of the camera lens from the listing page first and then go to its detail page to get the specifics. We have two methods to achieve these needs.
1. Use Auto-detect web page to create a workflow
The smart detection feature in Octoparse 8.X is more powerful than ever. We can use it to detect the webpage to save us some time.
Click Auto-detect web page data in the Tips box and wait for it to complete
Switch between the auto-detect results to find your desired data fields (result 1 in this case)
Check the data fields on Data Preview section and delete unwanted ones
When we search for popular product lines like the one we use to demonstrate, chances are that we need to navigate through multiple search result pages and extract data from each one of them.
Click on the Check button to see if Octoparse has successfully located a next page button
Uncheck Add a page scroll and click Create workflow
Octoparse has now created a Loop Item in the workflow, which can help to scrape from the search results page. We will continue to build the steps to go to detail pages.
Select Select subpage URL
Choose a field with the URLs you want to click to Confirm
Now Octoparse has taken us to the detailed page for further data extraction. We can take down the information we want from the page.
Click on any web element you want to extract
Click Text from the Tips panel
Modify the data field names in the Data Preview section by double-clicking on the field header
2. Manually create the workflow
If the auto-detect function fails for some websites, we can also set up the workflow manually. See the steps below:
Select the first item on the list page
Continue selecting the second item
Click Text
A Loop Item has now been added to the workflow, but only one field has been scrapped. We can add other fields.
Select any information you want to scrape from the results page
Choose Text
Repeat the steps above to add more fields
Then we need to build an action to click on the product title URL.
Select the first title on the list page
Click Click element
Once we are taken to the detail page, we can extract the information from the Item specifics.
Click on any web element you want to extract
Click Text from the Tips panel
Modify the data field names in the Data Preview section by double-clicking on the field header