Skip to content

Instantly share code, notes, and snippets.

@echain
Created May 20, 2012 01:53
Show Gist options
  • Save echain/2733227 to your computer and use it in GitHub Desktop.
Save echain/2733227 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import urllib
import urllib2
import time
params = urllib.urlencode({'a': 'smt20120609', 'p': '/SMT1', 'fn': '1_Sheet1', 'pd': '1'})
req = urllib2.Request('https://www.ragic.com/sims/form_update.jsp')
req.add_header('Referer', 'https://www.ragic.com/smt20120609/SMT1/1')
# add cookie info. for filtering, which could be defined manually from official site
req.add_header('Cookie', 'JSESSIONID=1cnik9e43pjsy1fw874efpyps6; tz=8; tooltip=true')
while True:
response = urllib2.urlopen(req, params).read()
data = response[6:].splitlines()
for _ in range(0, len(data), 8):
if not data[_].startswith('D'):
break
attr = []
for n in xrange(7):
attr.append(data[_ + n].split(',')[-2])
if attr[1] == '已交易' or attr[2] != '4200':
continue
# delete status and price column
del attr[1:3]
print('[', ', '.join(map(str, attr)), ']')
time.sleep(60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment