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.


    safari appex.get_web_page_info

    Pythonista
    5
    5
    5682
    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.
    • itribs
      itribs last edited by itribs

      in Safari

      import appex
      print(appex.get_web_page_info())
      

      return {}

      import _appex
      print(_appex.get_input())
      

      return

      [{'attachments': [{'com.apple.property-list': b'bplist00\xd4\x01\x02\x03\x04\x05\x06\x08\tX$versionX$objectsY$archiverT$top\x12\x00\x01\x86\xa0\xa1\x07U$null_\x10\x0fNSKeyedArchiver\xd1\n\x0bTroot\x80\x00\x08\x11\x1a#-279?QTY\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00['}]}]
      

      iphone7 ios 11.3(15E5167f)
      pythonista3.2

      1 Reply Last reply Reply Quote 1
      • pseufaux
        pseufaux last edited by

        I am getting the same thing about 1/2 of the time when I use appex.get_url() to get a shared url from Safari. To test this I am using the built in demo “URL to QR Code. When it works, the QR code appears quickly. When it does not, then the extension does nothing for about 2 seconds and then shows “No input URL found.” Both of these will happen on the same page, and it seems that once it finds no input the page will not work again until I force close Safari. Sometimes it finds no input on the first run and sometimes it take two or three runs. This does not happen when using other browsers.

        Context Notes:
        Pythonista Version - 3.2
        iOS - 11.2.6
        iphone 8 plus

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

          Same here using appex.get_url(). Only works half the time.

          Pythonista 3.2
          iOS 11.3 (15E5216a)

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

            This is only a stab in the dark. But often when I have had problems with something that works some of the time and not other times. The answer is normally relates to timing, ui/blocking etc.
            So using the @ui.in_background decorator could help with the ui blocking, sometimes calling time.sleep(1) can help. As I say I am guessing, but I recognise the general pattern of sometimes this works other times it does not from the problems I have had. A ui blocking or timing issue. Hope it helps, I know others here could be more concise to the exact problem, maybe this is enough food for thought.

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

              This issue is really annoying me. Oddly enough, it works 100% of the time on my iPad. On my iPhone, however, functions using appex from Safari only work ~25% of the time. It doesn't matter whether I try to get the URL or web page data directly.

              Is there anything I can do to make this work on the iPhone the way it does on the iPad?

              Here's an example of a general script I use to see what comes through the share sheet:

              import appex
              from bs4 import BeautifulSoup
              
              
              def main():
                  if appex.is_running_extension():
                      print(f'# APPEX DATA #\n{"=" * 15}\n')
                      methods = [
                          method for method in dir(appex)
                          if callable(getattr(appex, method)) and
                          method.startswith('get') and method != 'get_input'
                      ]
                      for method in methods:
                          result = getattr(appex, method)()
                          name = method.partition("_")[2]
                          if result:
                              print(f'{name}\n{"-"*15}')
                              if name == 'web_page_info':
                                  for k, v in result.items():
                                      if k == 'html':
                                          soup = BeautifulSoup(v, 'html.parser')
                                          v = soup.prettify()
                                      print(f'{k}: {v}')
                                  print('\n')
                              else:
                                  print(f'{result}\n\n')
                  else:
                      raise ReferenceError(
                          'Requires appex: (must be run from iOS share sheet!)')
              
              
              if __name__ == '__main__':
                  main()
              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors