Getting text from source code

830 views
Skip to first unread message

Adrian Sadkowski

unread,
Jul 6, 2016, 6:04:13 AM7/6/16
to MIT App Inventor Forum
Hey guys,
Maybe someone has an idea how can I:
1. get source code of a webpage in MIT app inventor (web-component is ok?)
2. find particular phrase in this code
3. paste it into aplication for exaple as "Label"
I've got to copy a text from a page and this page doesn't offer API.

Maybe this would be useful "How to parse a result" (https://puravidaapps.com/snippets.php#2parse). I just want to use source code instead of "string".

Taifun

unread,
Jul 6, 2016, 9:32:37 AM7/6/16
to MIT App Inventor Forum
set Web.Url to http:///example.com/yourPage.html
Web.get

and in the Web.GotText event receive the source code of that page and use the parse procedure

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Adrian Sadkowski

unread,
Jul 6, 2016, 9:47:03 AM7/6/16
to MIT App Inventor Forum
I used web component and set url but i don't understand what do you mean by "and in the Web.GotText event receive the source code of that page and use the parse procedure"
i don't know how to connect procedure and web.gottext.

Taifun

unread,
Jul 6, 2016, 9:54:04 AM7/6/16
to MIT App Inventor Forum
the string in your case is the response content of the web.gottext event


A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
 Top 5 Tips: How to learn  App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by  Taifun.         



Adrian Sadkowski

unread,
Jul 6, 2016, 10:00:46 AM7/6/16
to MIT App Inventor Forum
Thanks for help :)

Adrian Sadkowski

unread,
Jul 6, 2016, 10:26:56 AM7/6/16
to MIT App Inventor Forum
Should it look like this?

Auto Generated Inline Image 1

Taifun

unread,
Jul 6, 2016, 11:13:45 AM7/6/16
to MIT App Inventor Forum
the url should be defined somewhere else, for example in a button.click event


also you forgot to use the Web.Get method
before being able to receive something in the web.gottext event, you first have to call Web.Get

ABG probably would explain it like this:
first you have to say "please give me some candy" (Web.Get) and then a little bit later you will get it (in the Web.GotText event)

btw. it helps to do the tutorials...

Taifun

Abraham Getzler

unread,
Jul 6, 2016, 11:45:31 AM7/6/16
to MIT App Inventor Forum
There's a whole section of Web API examples near the end of this FAQ ...

If you're analogy hungry, consider ..
  Fire, Aim, Ready; what's wrong with this order?

ABG

Pavitra Golchha

unread,
Jul 6, 2016, 3:25:22 PM7/6/16
to MIT App Inventor Forum
thanks u gave me a billion dollar idea
Reply all
Reply to author
Forward
0 new messages