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.


    [Resolved!] Error in appex's script

    Pythonista
    2
    3
    2952
    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.
    • beer2011
      beer2011 last edited by

      Hello,All.
      Error in appex script, can not be eliminated.
      Please give me advice .
      As the goal, From the open page (Internet), it is what you want to download and save images .
      Thanks.

      download_image.py

      http://news.goo.ne.jp/topstories/nation/379/8badd8f273cceb69bac12a775d978555.html?isp=00002
      //u.xgoo.jp/img/goo.png
      Traceback (most recent call last):
        File "/private/var/mobile/Containers/Shared/AppGroup/1920E896-A5A8-4781-B249-EE90E9CC5C44/Documents/download_image.py", line 43, in <module>
          main()
        File "/private/var/mobile/Containers/Shared/AppGroup/1920E896-A5A8-4781-B249-EE90E9CC5C44/Documents/download_image.py", line 40, in main
          download(img_url)
        File "/private/var/mobile/Containers/Shared/AppGroup/1920E896-A5A8-4781-B249-EE90E9CC5C44/Documents/download_image.py", line 13, in download
          img = urllib2.urlopen(url)
        File "/private/var/mobile/Containers/Bundle/Application/BA72C9F4-3A16-4501-889D-1505A8733CDE/Pythonista.app/PlugIns/com.omz-software.Pythonista.PythonistaAction.appex/pylib/urllib2.py", line 128, in urlopen
          return _opener.open(url, data, timeout)
        File "/private/var/mobile/Containers/Bundle/Application/BA72C9F4-3A16-4501-889D-1505A8733CDE/Pythonista.app/PlugIns/com.omz-software.Pythonista.PythonistaAction.appex/pylib/urllib2.py", line 397, in open
          protocol = req.get_type()
        File "/private/var/mobile/Containers/Bundle/Application/BA72C9F4-3A16-4501-889D-1505A8733CDE/Pythonista.app/PlugIns/com.omz-software.Pythonista.PythonistaAction.appex/pylib/urllib2.py", line 259, in get_type
          raise ValueError, "unknown url type: %s" % self.__original
      ValueError: unknown url type: //u.xgoo.jp/img/goo.png
      
      
      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        Haven't tried it, but I think something like this should work:

        #[l.36] get image's URL
                img_url = link.get('src')
                if img_url.startswith('//'):
                    img_url = 'http:' + img_url
                # [...]
        
        1 Reply Last reply Reply Quote 0
        • beer2011
          beer2011 last edited by

          @omz
          Thank you , I was resolved ! (^^/
          Always , I received a precise advice , we are surprised .
          A new version(Pythonista) of the provision , we are looking forward .

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