Hi There Community - I’ve been able to successfully google-search a list of terms from an excel file (using for each row activity) and save the results in a data table. However, how can I get each searched term to appear as a column alongside in my data table of search results so that I know which results pertain to which searched term?
So basically I believe the excel file has a list of URL’s which you access in the loop. Then you go to that page, get some data and store in a datatable.
I have one question here. How are you adding the data of the web site to your datatable? Is it coming through web scraping? Or are you getting the values to individual variables and then adding the data to the datatable using a Add Data Row activity?
So here is my process so far:
- I created a list of keywords that I want to search in google within an excel file.
- I have the bot open up google within a browser.
- I then, using a “for each row” activity, have the bot input the keyword, get the first 20 results (using data scraping wizard), and output them to a data table.
- I then have the the bot repeat the process for each keyword within my excel file
Right now, my output data table only includes 2 columns: 1.) Search results and 2.) URL of each search result
I would like my output data table to include 3 columns: 1.) Searched Keyword (from my excel file) 2.) Search results 3.) URL of each search result.
Hope that clarifies!
Cool… now I understand the scenario…
I guess it will be easier to share a sample worflow with you on how to do this… Give me couple of minutes. .I’m working on a sample for you
So I have created a sample workflow for you. However, I didn’t actually do the data scraping part since you already know how to do it. But I added the extract structured data activity to simulate your data scraping. So if you are using my workflow, your data scraping should be added to that location
So what happens here is this…
- Read Range to extract the keywords to a datatable
- Build another datatable with three columns to hold the final results
- Loop through the keyword datatable using For Each Row activity
- within the loop, do the google search and extract the data to a datatable
- Add a column to the datatable that was generated through the data scraping to hold the keyword
- Loop through the scraped data and add the keyword to the new column
- Merge the results to a final datatable that holds all the scraped data while it is ready to write the data to excel
- Then finally, write the data
Note: Since I haven’t done the scraping, it has a error there… So don’t worry about it much… I just want to show the workflow on how it should be done
LoopingThroughAndAddingColumns.xaml (15.4 KB)
Let know whether this works for you…
Once my “for each row” loops through once on the extracted data, I’m getting an error on the “Add Column” activity saying that the column named “Keyword” already belongs to the data table. Any idea how I can go about resolving?
Appreciate your help on this!
The error says the column name is already available because it cannot have two columns with the same name. Make sure you add it only once