A2019 Pattern Based Data Extraction | Automation Anywhere

 RPA | A2019 Pattern Based Data Extraction| Automation Anywhere - Part-39


A2019 pattern based data extraction  - In this blog we will explore about the another useful concept i.e. pattern based data extraction. We will also cover the practical implementation to extract the pattern based data extraction from the website using A2019 Automation Anywhere community edition.

So before we start the steps to discuss on how to extract pattern based data let us first discuss the types of data that we have i.e. regular data and pattern based data. In this blog we will discuss about pattern based data extraction.

Pattern based data means the data which forms a continuous pattern or create a sequence or series such as in arithmetic progression series there is continuous pattern being formed i.e. between two numbers there can be a difference of either 1 or 2 etc. So if we talk about the pattern being formed in a website there is a continuous pattern is formed when we search for any product on the e-commerce website i.e. in the HTML properties there would be either div element number that would be changing or other element properties would be changing in a sequence of pattern. 

So in this blog how we can extract pattern based data from one of the famous e-commerce website i.e. from flipkart using A2019 Automation Anywhere.

So before discussing the steps let us discuss the scenario that we would be covering during this blog.

Use case scenario Steps-

  1. Extract details of all the Samsung mobile phones i.e. description and the price of each mobile phone from each of the pages that exists.
  2. Once all the details are extracted write the extracted data into the text file.
So now we will discuss the steps that would be required for extracting the data from the website which are as follows:
  • Drag and drop the loop condition to check if the next button is present on the webpage or not. In the properties section select the while loop and select Recorder object and capture the next button and check the "check the condition at the end of iteration" checkbox.
  • Inside this while loop create a flag variable and assign this variable a numeric value of 1 and then check if flag variable is not equal to 1. If this condition is satisfied inside this if condition drag and drop the recorder action to capture the next button.
  • Assign the counter variable as 2.
  • Now again drag and drop the while loop which will keep track of the items extraction from the webpage.
  • Inside this while loop drag and drop the recorder action again to capture the description and the price that are present on the webpage.
  • Now drag and drop the log to file action to write the extracted data to a text file i.e. write the description and the price into the text file.
  • Increment the counter variable and the flag variable by 1.
  • Repeat the above steps until all the items are extracted for each and every page of the website.
Now you might be wondering as to how to pass the dynamic values to the HTML properties whose numeric values are changing so now let's discuss as to how to make them dynamic.

So let us consider the two XPath here which are as shown below.

  • //div[@id='container']/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/a[1]/div[2]/div[1]/div[1]
  • //div[@id='container']/div[1]/div[3]/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]/a[1]/div[2]/div[1]/div[1]
So from the above two XPath you can see the difference that one of the div elements is changing with the difference value of 1. So now to make it dynamic we have created a counter variable which was assigned a default value of 1. So now we will pass this counter variable in that div element whose numeric value is changing. So now the modified XPath would look something like this as shown below.

//div[@id='container']/div[1]/div[3]/div[1]/div[2]/div[$vCounter.Number:toString$]/div[1]/div[1]/div[1]/a[1]/div[2]/div[1]/div[1]

So as shown above this is the method through which we can create dynamic XPath in the case where the properties of XPath changes.




So with that we have come to the end of our blog where we discussed how to extract pattern based data extraction using A2019 Automation Anywhere.

If you have any queries related to this blog then you can raise your queries in the comment section and I will be more than happy to resolve all of your queries.

Lastly I would request all of you to please share your feedback as your feedback really matters the most to me.

Comments