How do I scrape data from Web?

:question: Do you mean webviewer ?

Spend 30 years working with html/css/javascript/VBA/Google etc., 12 years working with AppInventor, and even then you will only have the tip of the iceberg. The internet is your friend when it comes to finding answers.

"Experience is the only genuine knowledge"

This however is a good place to learn: https://www.w3schools.com/

running a javascript in a webviewer will work whether the webviewer is visible or not.

Can't really help with your blocks, other than to observe that they look very confused, and it is not obvious as to what you are trying to achieve: you use Kodular, a webviewer and customwebview in your blocks, plus procedures that you do not show.

Visible = false

No Web Component in connectivity section

The problem is now solved by my hit and trial method which i think is temporary.

I want to scrape data to web to string.
span class = compare needed and span class = current

There should be sufficient examples in this thread already for you to resolve this.

I am not good and best in js please help me master, I tried with

window.AppInventor.setWebViewString(document.querySelectorAll('span.compare')[0].innerHTML)

It is not working.

The query looks OK:

image

This is working for me:

window.AppInventor.setWebViewString(document.querySelectorAll('span.compare')[0].innerHTML)

I have only one webview can I run multiple request at same time, but how to identify the particular request in it?

Add a marker / id to the setWebViewString command.

In which place and how?

I am using this method to identify my javascript.

this is not returning value on the first click,but giving value on second click instantly.

Guide me where I am Wrong Matser @TIMAI2

You could do this, which returns a stringified json:

window.AppInventor.setWebViewString('{"compare": "' + document.querySelectorAll('span.compare')[0].innerHTML + '"}')

{"compare": 'Rs. 1,299.00"}

1 Like

You could also make several calls in one go:

window.AppInventor.setWebViewString('[{"current": "' + document.querySelectorAll('span.current')[0].innerHTML + '"}'+ ',' + '{"compare": "' + document.querySelectorAll('span.compare')[0].innerHTML + '"}]')

[{"current": "Rs. 699.00"},{"compare": "Rs. 1,299.00"}]

What is the meaning of WebViewString and why and what is the usage of this in Webview?

As of now I read, it is basically to connect Website using javascript to the app with webviewstring property...

Help me Master Tim.

I am confused, if when my clock do, the evaluate js not working,
but for the MRP Label it is working, I experiment it by placing a notifier in the block, the MRP label clock and blocks are working But I can't be able to get the value of PriceLabel to the label.



This is my full webview string block :

Looked a mess even before you drew all over it :wink:

Explain in words the workflow, it is difficult to see, even from your blocks, what you are hoping to achieve.

  1. I do Evaluate webString to get image from the website in the webview.

  2. In the same webview i ran another JS which was for MRP (span.compare)

  3. Same webview ran another JS to get the Discounted amount Price(span.current)

  4. In all JS evaluation i put some seconds of time to not get bulky the server.

  5. The first clock to get images is working fine and second to get MRP(span.compare) is also working fine but the third clock for Price(span.current) is not starting infact same starting as after the image got and MRP clock.

Why not just return the whole lot in one call, as I suggested above...

How to distinguish between them?(i know about this.)

But problem solving my mind ask me to solve this bug and improve it as it is with one by one as this help me to execute multiple JS in one webview and also helps me to idetify each Execution by Javascript variable. :smile: This is for my learning approach