With ParseHub you can add a list of keywords to be searched through into a search box. You don't have to manually add one keyword at a time, or wait for your project to finish for one keyword before changing it to another.
In this tutorial, we'll show you how you can add a list of keywords in JSON format into the Starting Value of the project in the Settings tab, and search for each of them to scrape the results.
For this tutorial we will use - http://www.amazon.com/ as an example. You can follow along using Amazon or you can apply the instructions to your own website and search form.
If you only need to input a single keyword into a search box, follow the instructions in this tutorial.
Entering multiple keywords
1. Open your project and any webpage of the website. Click "New Project" from the desktop app. When you enter the right url click "Start project on this URL".
2. Go to the "Settings" tab of the project.
3. You will need to add a list of the keywords you would like to search for into the "Starting Value" textbox. There are two possible ways of doing this:
- Use the "Import from CSV/JSON" option to import a list of keywords from a CSV file
- If you are familiar with JSON, paste your JSON directly into the textbox
If you are importing from CSV, ensure that your CSV file has the name of the list (such as "keywords") as the column header, with each keyword in a separate row:
Below is what the following list looks like in JSON format and is what will appear in the "Starting Value" textbox when you choose the "Import from CSV/JSON" option next to it and select a CSV file like the one above.
9. Click on the + button on the right side of the "For each item in keywords" command. Click on the "Advanced" arrow to show all of the tools.
10. From the tool box choose the "Begin New Entry" tool. Now the results for each one of the keywords will go into a separate row in Excel and a separate scope in JSON. If you don't use the list tool anywhere in your project, the results scraped for each keyword will overwrite one another.
11. Rename the "list1" command to something else like "type". Make sure not to name the list command the same as the list that holds your keywords. The list command should have a unique name.
12. Click on the + button on the right side of the "type" command or, if you didn't rename it, the "list1" command.
13. From the tool box select the "Select" tool.
14. Click on the search box. An input command will be automatically created for you.
15. Instead of typing the actual keyword, just type in "item". This will tell ParseHub to add in the keyword that is represented by the item in the list of your types of jewellery.
16. From the input command options, select "Expression" from the dropdown. ParseHub will read the text as an expression instead of just plain text.
17. Now you have an option to extract each keyword in your list along with the related results. This step will add a new column for the keywords that you provided as the starting value.
Click on the + button on the right side of the "type" command or, if you didn't rename it, the "list1" command and choose the Extract command. Instead of $location.href enter item and rename the Extract command to "searchterm". In your final results you will have a column which extracts the associated keyword for each result.
18. Click on the + button on the right side of the "type" command or, if you didn't rename it, the "list1" command.
19. From the tool box select the "Select" tool.
20. Now, click on the search button on the page. A selection command should appear for you.
21. Click on the + button on the selection that you just made. From the tool box choose the "Click" tool. The click tool lets you click on anything on the page to open drop downs, tabs, etc or to click on buttons that will take you to another page.
22. In the pop-up, when asked if it is a "next page" button, click "No" and select the "Create New Template" option. Clicking on the button will product a new page of results, therefore, you should be creating a new template to make a new set of instructions. Remember, you should use a new template for every page that looks different.
24. In the text-box in the pop-up type in "products" and click "Create New Template". A new template should be created for you.
25. On the new template, you can go ahead and select and extract any of the results that you want to scrape. ParseHub will repeat the instruction of searching for the keyword and scraping results for all of the keywords you added into the "Starting value".