How to get the source code of a page in native browser

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
fredericBUSjJet
Posts: 4
Joined: Mon Feb 18, 2013 4:01 pm

How to get the source code of a page in native browser

Post by fredericBUSjJet » Tue Feb 19, 2013 3:40 pm

Hello All.

i would like to try to get the content of a native broswer page i've created with " iphoneControlCreate "browser" when the " on browserFinishedLoading pUrl " is handled

anyone can give me the syntax ?

thanks a lot
fred

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How to get the source code of a page in native browser

Post by endernafi » Tue Feb 19, 2013 5:37 pm

Hi Frederic,

Well, that's easy.
I love LiveCode 8)

Code: Select all

on browserFinishedLoading pUrl
   answer url(pUrl)
   -- or
   put url(pUrl) into url("file:" & specialFolderPath("cache") & "/theSourceCode.txt")
end browserFinishedLoading
Hope it helps...


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

fredericBUSjJet
Posts: 4
Joined: Mon Feb 18, 2013 4:01 pm

Re: How to get the source code of a page in native browser

Post by fredericBUSjJet » Tue Feb 19, 2013 6:35 pm

got it. thanks so much.
i <3 too livecode

fredericBUSjJet
Posts: 4
Joined: Mon Feb 18, 2013 4:01 pm

Re: How to get the source code of a page in native browser

Post by fredericBUSjJet » Tue Mar 19, 2013 6:50 pm

sorry another detail

i would like to put a button beside my browser field to get the sources of the browser content at anytime without reloading the page

do you have any idea ?

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How to get the source code of a page in native browser

Post by endernafi » Tue Mar 19, 2013 6:56 pm

Hi Frederic,

Put this into your button's script:

Code: Select all

on mouseUp
   put "http://www.example.com/" into tUrl
   answer url(tUrl)
   -- or
   put url(tUrl) into url("file:" & specialFolderPath("cache") & "/theSourceCode.txt")
end mouseUp

Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How to get the source code of a page in native browser

Post by endernafi » Tue Mar 19, 2013 7:00 pm

This one's better:

Code: Select all

on mouseUp
  put mobileControlGet("myNativeBrowser", "url") into tUrl
  answer url(tUrl)
  -- or
  put url(tUrl) into url("file:" & specialFolderPath("cache") & "/theSourceCode.txt")
end mouseUp
Replace myNativeBrowser with the name of your browser control


Best,

~ Ender Nafi
Last edited by endernafi on Tue Mar 19, 2013 7:00 pm, edited 1 time in total.
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

fnajmanBUSNPJd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10
Joined: Mon Jan 14, 2013 11:11 am

Re: How to get the source code of a page in native browser

Post by fnajmanBUSNPJd » Tue Mar 19, 2013 7:00 pm

thanks but the web site i am trying to get sources is in ajax and i would like to get the content of the page at different time when i am browsing in
something like " put iphonecontrolGet(sbrowserid, "text") into fld myTextField " maybe

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How to get the source code of a page in native browser

Post by endernafi » Tue Mar 19, 2013 7:05 pm

Look at my second post...
{ put mobileControlGet("myNativeBrowser", "url") into tUrl }

If this doesn't work for you then I didn't understand what you actually mean, sorry...


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

fnajmanBUSNPJd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10
Joined: Mon Jan 14, 2013 11:11 am

Re: How to get the source code of a page in native browser

Post by fnajmanBUSNPJd » Tue Mar 19, 2013 7:09 pm

thanks a lot for your help , i am sorry about my poor english
in fact the content is in javascript and ajax i guess
so content is dynamic inside the page
if i get the sources code i don't see the dynamic content in fact.
idea: is it possible to do a copy - paste inside a native browser ?

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How to get the source code of a page in native browser

Post by endernafi » Tue Mar 19, 2013 7:14 pm

There may be some workarounds.
Could you post the link whose content you're trying to retrieve?
I could give a try, then.



~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

fnajmanBUSNPJd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10
Joined: Mon Jan 14, 2013 11:11 am

Re: How to get the source code of a page in native browser

Post by fnajmanBUSNPJd » Tue Mar 19, 2013 9:46 pm

thank you so much
i don't have permission to post link i hope you can understand this one
www(dot)demo(dot)index-education(dot)net/eleve.html

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How to get the source code of a page in native browser

Post by endernafi » Tue Mar 19, 2013 11:29 pm

Hi Frederic,

Well, I'm sorry to request the link;
I didn't realize that it may be a special web service.
I thought that it's a generic webpage :oops:

I managed to get the content
and although the code of that web service is obfuscated, the data can be processed.
Since the subject is no longer directly related to iOS, we should continue this discussion off-list.
Please contact me at endernafi@gmail.com, I'll try to help - if I can 8) -

If we could generate an over-all solution, we'll post it here.


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

Post Reply