HOW TO EXTRACT DATA ON WEBSITE STEP BY STEP WITH iMACRO

Hello, Today I will present How to get data on website step by step with iMacro.

First Step we have to check elements of HTML at point is we want.
In example I want to get title product first, I will right click at title and click to menu Inspect Element.

You will see section Inspector showed.
And see to blue tab is current in HTML, In example blue tab current in tag H1.
OK. Now we know title stand in HTML name H1.

I will press button record iMacro and click at title And press stop button.
Go to file #current.iim.
Right click and click edit macro.
I will delete text in line number 3.
OK. Now you will see imacro record tag H1 from the page.
After that I will use command EXTRACT=TXT after last word in line 4 and press save button.

***All detail in this page you need to see the video to understand.
How to extract data on website step by step with iMacro
How to extract data on website step by step with iMacro

How to extract data on website step by step with iMacro

We will test iMacro code.
I will click #current.iim and go to Play button and press this button.
Now. We will see alert popup in the page is show text title. OK, Our code is works.
Now. I will put command SET EXTRACT TEST POPUP NO in file #current.iim, And in line 5 I write command PROMPT EXTRACT.
Don't forget Curly bracket in command EXTRACT. See example in video.
After that run code again.

Now you will see popup from PROMPT command is show text title products.
OK. I will put command for save text to CSV file.
Line 5 command wait seconds in 5 seconds.
And line 6 command save variable from EXTRACT to exsample.csv file.
After that test code again.
Now. iMacro can save example file to directory success. I will open this file with LibreOffice program.
We can see title product was saved.
OK. I will close this file. So every time open csv file by LibreOffice or Microsoft Excel. After run iMacro you must close csv file first.
If you don't close file first. iMacro will be can't save every data to csv file.


OK. Next step, I will try to get item specifics section in the page.
Same last step, I will right click in point is I want and click Inspect Element menu.
We will see this text stand in span tag. But we want all of the text in this line. So I will move focus to parent Node. That is L I tag.
So. we will see all L I tag cover all text is we want.

Back to #Current.iim I will copy line 4 to line 6 and paste in this file. See example in video.
After that I will edit code line 7.

OK. Before next step I want to rename file to A-exsample.iim.
After that I will press record button and click on Brand Name and Type in the page.

Open #current.iim file and edit value in TYPE from SPAN to L I.

Value in A T T R.
I edit from old text to attribute ID value product-prop*.
And write command extract=TXT to this line.

After that I will test this code.
If you see pop up show in the page and in popup must display text Brand Name MOM'S HAND showing that our code is working.

I will open file #Current.iim and copy code in line 4 and replace line 7 in file A-exsample.iim.

After that test this code and see result in exsample.csv.
You will see that the information has been added to the file.
But New data is not in the same line. OK. Hold on to this step.

Back to A-exsample.iim file copy code line 7 to line 10.
And past in new line and edit code for next L I and do it again for all L I in this section.

So we must remember iMacro Can not distinguish difference Of each L I tag.
So we will use the difference between position of L I in the page set target point for iMacro get data.

We have to change number of tag P O S in iMacro. See example in video.
Back to before hold on code.
We will clean up the command new line.

See example in video.
Line 9 that code for clean up command new line.

We will write this code on command EVAL and result this code to variable VAR1.
In Eval code we create variable name exam for get data from EXTRACT.
And use command replace of JavaScript clean up command new line with regular expression by empty.

After that I test this code.

We can see command new line is clean up, but we have space too much.
We need to clear excess space. So code for fix it showing in line 10.
Again we will use command replace of JavaScript clean up excess space with regular expression by empty again.

See example in video.

Test code and see result in exsample.csv.
You will see each set of data is included in the same line.
Next step we will include every line in to the same line.

First step I remove each for command saves and leave the last line Only one. See example in video.

After that we will create own variable name V A followed by number 1 2 3 and more for support all data sets.

And before command saves we write command imacro extract null for clean up old data in command extract.
After that we will use command SET EXTRACT for own variable VAR 1.

And next line we will use command ADD EXTRACT for each own variable.
After that test code again see result in exsample.csv.

You will see all data include to one line.
Next target point I will get text price in the page.

Same step again, I will right click on text price and click inspect elements menu after that inspector will show up.

You will see blue tab current elements is you click.
So, if that blue tab does not cover text price we must move blue tab to parent element.

See example in video.
After that press record button on iMacro and click target point on the page and click stop button.

Go to #current.iim click edit macro.
Remove text in line 3 - 4.
Now we have focus in line 3.

Click Edit value at command TYPE on line 3 to element DIV.
And command A T T R click edit value to attribute class.
So attribute class we talk is attribute class on the page.

We must select only one of all attribute and write name and value of that attribute in iMacro.

See example in video. And so remember this every time you choose to attribute class in the page.

You must write * before and after value of class.
Because attribute class can have more than one of value.
If we choose only one of all value we must write * before and after that value.

After that use command EXTRACT=TXT after last text in line 3.
And line 4 I use command PROMPT for recheck result of code.
Press button play for test imacro code. If popup show text price that our code is works.

But now. Text price is showing too many gaps, and we want is the price number.
But in pop up show text mix number,
We need to remove excess space to normal space and remove all text except price number.

In line 5 I write code for remove all text.

I create iMacro variable and use command EVAL.
In command EVAL I create variable name S S for get variable extract and use command replace of JavaScript To replace all text in variable s s.

In command replace of JavaScript I use Regular Expressions for delete only text message and This code will remove excess space too.


Test code and see result.

We will see only number of price in pop up.
After that copy this code and past to A-exsample.iim before command saves of iMacro.

And run A-exsample.iim again.
See result in LibreOffice program.
We will see number of price in this file.
Next point we will get detail of products.
Same last step. I will right click on detail point go to click inspect element menu for check this element.

Try to choose elements is cover all text detail.
In video element is cover all text detail is element DIV and value of class this element is description-content.

I will test this value by search tool on Inspector section.
If this value of class show search result only one all the page, We can use this value in iMacro.

But result search more than 1 we have to choose to parent elements and test by search again.

In this video. Result of search show only one in use.
I will be chosen this value of class in imacro.

Problem is. In this section has widget other products.
So we don't want this widget and I will be use command of jQuery for remove all widget.

First step we must add jQuery API to iMacro.
So. I will expand jQuery API for you understand all code jQuery API.

See example video. You will see code we use in iMacro.
When implementing code with iMacro.

We will use with command URL GOTO and end code by void(0).

After we use command add jQuery at line 4 we will use command wait seconds and write number 1 for imacros wait 1 seconds.

After that in video line 5 to line 7 we use command remove of jQuery for choose to attribute title and 2 value for focus is HOT SELLING PRODUCTS and KITCHEN ACCESSORIES. See example in video.

Test code we will see 2 widgets is gone.

After that you can write command imacro for get detail. Same step data is we get too many gaps and have a line break. We have to remove it.

I use same command of JavaScript for text detail. See in example.
And this is video show how to use imacro get data from the page.
You can customize For use with other web. See you next time. Bye.
Download example Code iMacro(iim) extract data on website Click this link : https://goo.gl/sHDcNM

No comments:

Post a Comment

SCROLL DOWN THE WEBSITE WITH iMACRO.

hello, Today I will present How to scroll down web site by iMacro. If you use iMacro for your jobs and you have a problem iMacro don't ...