Skip to content

Instantly share code, notes, and snippets.

@zhichenghou
Created April 24, 2015 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhichenghou/d710dcfca37f970c5489 to your computer and use it in GitHub Desktop.
Save zhichenghou/d710dcfca37f970c5489 to your computer and use it in GitHub Desktop.
ezfm 飞鱼秀 回放
# -*- coding: utf-8 -*-
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
import urllib2
import json
def getPlayList():
response = urllib2.urlopen("http://ezfm.china-plus.net/index.php?m=index&a=cat_list&cid=224").read()
result = json.loads(response)
return result['data']
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
datas = getPlayList()
html = '''
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h2> EZFM 飞鱼秀 回放 </h2>
<table cellspacing="8">
<tr>
<th>Title</th>
<th>Url</th>
<th>Update time</th>
</tr>
'''
for data in datas:
html += '''
<tr>
<td>''' + data['title'].encode('utf-8') + '''</td>
<td><a href=''' + data['url'].encode('utf-8') + '>' + data['url'].encode('utf-8') +'</a>' + '''</td>
<td>''' + data['update_time'].encode('utf-8') + '''</td>
</tr>
'''
html += '''
</table>
</body>
</html>
'''
self.send_response(200)
self.end_headers()
self.wfile.write(html)
def start_server():
http_server = HTTPServer(('', 8080), Handler)
http_server.serve_forever()
if __name__ == '__main__':
start_server()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment