Cannot extract data from webpage to an excel sheet

I’m trying to copy the details on all the items from ‘TODAYS DEALS’ given in the AMAZON WEBSITE into an excel sheet but I’m always getting an error ‘FAILED TO WRITE INTO EXCEL’. The data to be extracted is not in a tabular form but in ‘div’ format. Can you tell me how to extract the data from a division in webpages.

My code:

APPMASK:

I have referred to your tutorial on extracting data from webapage and saving it as an excel file but still it did not work for me.

Hello @Yash_bitla99,

ExtractHtmlTable actions do what they say, they extract HTML tables.
In case you want a different element you must utilize the GetDetailsOfElement action.

please take a look here regarding data extraction:

Best regards,
J.

I still cannot access the data of the webpage. Can you write the code for it and show me? (For the problem I have psoted above)

Maybe this will help a little, @Yash_bitla99 . I haven’t done any of the Excel code, just accessing the attribute. The appmask is different than yours (so is the price of the phone :grinning:).

Mask:

Screenshot of code:

Output:

output

Code itself:

import "C:\Users\yash\Documents\Robin\forum\Yash_bitla99_1.appmask"


WebAutomation.LaunchChrome          Url:  "https://www.amazon.in/gp/goldbox" \
                                    WindowState:WebAutomation.BrowserWindowState.Maximized \
                                    ClearCache:true \
                                    ClearCookies:False \
                                    BrowserInstance=> Browser

wait 3

WebAutomation.PopulateTextField     BrowserInstance:  Browser \
                                    Control:  Yash_bitla99_1.AmazonGoldBox.MainSearchBox \
                                    Text:  "xiaomi mi a2 gold, 64gb"\
                                    EmulateTyping:True \
                                    UnfocusAfterPopulate:False


wait 0.2


wait 0.2

WebAutomation.PressButton           BrowserInstance: Browser \
                                    Control: Yash_bitla99_1.AmazonGoldBox.SearchSubmit

wait 3

WebAutomation.GetDetailsOfElement   BrowserInstance:  Browser Control: Yash_bitla99_1.Xaomi.A2 \
                                    AttributeName:  'innerText' \
                                    AttributeValue=> AttributeValue

Console.Write                       Message: AttributeValue

wait 4

WebAutomation.CloseWebBrowser       BrowserInstance: Browser

You could write the output to an Excel cell instead of the console, of course.

That said, I get the feeling you want to extract all the “div” elements related and write that data to Excel, as if it were a table. I’m not there yet … I’ll work on it.

Regards,
burque505

1 Like

This will do. Thanks alot

1 Like