I'm trying to logging text from this URL site: http://radio.nolife-radio.com:8000/played.html into a text file. I've decided to try using the Python Logging module. So far I got nothing, I have been reading some here: http://docs.python.org/dev/library/logging.html Not sure if I should use the SocketHandler or HTTPHandler. I'm quite new to this and still looking through the tutorials. There might be an easier solution using Urllib or something I don't know. The URL site is a radio station and is updated after each track. I want the updated information to be logged. Here is the progress so far:
import logging, logging.handlers
logger = logging.getLogger('Radio Station')
logger.setLevel(logging.INFO)
fh = logging.FileHandler('thread.log')
fh.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
fh.setFormatter(formatter)
logger.addHandler(fh)
host = 'localhost:8000'
url = 'www.radio.nolife-radio.com:8000/played.html'
http_handler = logging.handlers.HTTPHandler(host, url, method='GET')
logger.addHandler(http_handler)
logger.info("")
The code above doesn't work at the moment. If I remove the HTTP code, this is the outcome:
2013-11-11 00:22:19,640 - Radio Station - INFO -
Any help would be appreciated.