第一个python程序

import time
import sys
import stomp
import urllib

def getHtml(url):
      page = urllib.urlopen(url)
      html = page.read()
      return html

class MyListener(object):
      def on_error(self, headers, message):
            print('received an error %s' % message)
      def on_message(self, headers, message):
            print('received a message %s' % message)

urls = message.split( )
for url in urls:
      print(url)
      html = getHtml(url)
      print len(html)
      #print html


conn = stomp.Connection10([('192.168.16.*',61613)])
conn.set_listener('', MyListener())
conn.start()
conn.connect()
 
conn.subscribe(destination='/queue/asyncUrl', id=1, ack='auto')
try:
while True:
  time.sleep(25)
except:
pass

conn.disconnect()

posted on 2015-11-30 17:56  阳光2046  阅读(251)  评论(0编辑  收藏  举报

导航