• pythonista

    @Phuket2 There is no attack at this URL a.f.a.i.k.
    @omz You helped me out of this trap, thanks...! About the encoding issue: It's a croatian website, I didn't care about the encoding they are using, yet...

    posted in Pythonista read more
  • pythonista

    Hi,

    being fairly new to python, but not to programming I have a problem with a script which runs beautiful on Windows python 2.7.11, but not in Pythonista on iOS. On iOS, although I can see by the length of the text I want to "print" to console, that there are roughly 2000 characters available, the console (or also tried, a text view) stays empty. Same for direct sys.stdout.write with flush. What is wrong?

    import webbrowser
    import httplib
    import sys
    from HTMLParser import HTMLParser
    
    class MyHTMLParser(HTMLParser):
        t=''
        def handle_data(self, data):
            if len(data) > 40:
               self.t = self.t + '\n' + data
        def get_text(self):
            return self.t
    
    class textfromweb:
        def get_weather_text(self):
            text = ''
            hc=httplib.HTTPConnection('prognoza.hr:80', timeout=50)
            hc.connect()
            hc.request("GET","http://prognoza.hr/prognoze_e.php?id=jadran_n")
            r = hc.getresponse()
            data = r.read()
            parser = MyHTMLParser()
            parser.feed(data)
            self.text = parser.get_text()
            hc.close()
            return self.text
    
    t = textfromweb()
    print t.get_weather_text()

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!