How to parse html page including java script?

Discussion in 'iOS Programming' started by mikezang, Dec 3, 2012.

  1. mikezang macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #1
    I try to parse a HTML page that use java script to create some content, I found stringWithContentsOfURL can't give me right result, because there is no contents created by java script, what can I do?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Embed a UIWebView (not necessarily visible), load the page, let the JS run and then interact
     
  3. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #3
    Can it be run in background like Safari?
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    If you mean whilst your app is suspended I suspect no. If you mean whilst your app is the active app then yes, it would load happily.
     
  5. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #5
    But it is said UI only can be run in Main thread...
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    1) I said nothing about threads: you have decided to add this
    2) An offscreen (or simply z-layered behind the other views) view implies nothing about threads
     

Share This Page