omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    How to interact | change | modify content inside an ui.webview in pythonista programmatically?

    Pythonista
    4
    4
    2691
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Pppi
      Pppi last edited by

      Hi pythonista's,

      is there a way to interact with content of a website loaded inside an ui.webview e.g. click on a link, push a button and so on and so forth programmatically with python in pythonista?

      thanks in advance

      -püppi-

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        Requests is probably a better way to download webpages and do HTTP POSTs to simulate interactions (filling in fields, clicking buttons, etc.) with them. However, Requests has a downside in that you do not actually see the web page as you would if you were using ui.WebView.

        1 Reply Last reply Reply Quote 0
        • dgelessus
          dgelessus last edited by

          WebViews also have an eval_js() method that executes a string of JavaScript code on the current page, that may help if you're working with links/buttons that run JS when pressed. In that case you could simply run the button's JS code using eval_js().

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            If doing a lot of 2way comm, requests is easiest to use. You can then display the result in a webview.

            For simple stuff, eval_js works well. You can use

            eval_js('document.documentElement.innerHTML')
            

            to get current page source. Then you can use bs4 for example to scrape the source.

            See http://www.w3schools.com/jsref/met_html_click.asp for an example of directly simulating a mouse click on an element like a button.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors