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.


    Auto fill

    Pythonista
    2
    4
    2923
    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.
    • reefboy
      reefboy last edited by

      Say I wanted to auto fill info into a website. Could I do that in a python script?

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

        it depends, but usually, yes.

        There are a few options, such as mechanize, requests, or webbrowser (using javascript to simulate clicks, etc). I tend to use bs4 along with requests.

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

          Ok also, how do I open a website in UI

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

            This should get you started.

            import ui,time
            w=ui.WebView()
            w.frame=(0,0,570,570)
            w.load_url('https://google.com')
            w.present()
            
            # make sure the page has finished loading
            time.sleep(1)
            while not w.eval_js('document.readyState') == 'complete':
            	time.sleep(1.)
            
            # using bs4 and requests to poke around, i know the textfield has a name of q
            # i can set the value using javascript
            w.eval_js('document.getElementsByName("q")[0].value="using javascript to fill in forms";')
            
            # i happen to know the name of the form is "f", i will submit the form
            time.sleep(1)
            w.eval_js('document.getElementsByName("f")[0].submit()')
            

            Other good searches might be "using bs4 and requests to fill in forms", or "how to use mechanize to fill in forms".

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