Skip to content

Instantly share code, notes, and snippets.

@jackyshan
Created February 1, 2016 04:53
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 jackyshan/8965112bf59d57f807ab to your computer and use it in GitHub Desktop.
Save jackyshan/8965112bf59d57f807ab to your computer and use it in GitHub Desktop.
黄金价格提醒
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re, urllib2, threading, os
resp = urllib2.urlopen('https://goldetfprod.alipay.com/gold/queryChart.htm?productCode=000930')
respread = resp.read();
pattern = re.compile(r'\[{"fundGoldPrice":\d+\.\d+');
match = pattern.search(respread);
if match:
s = match.group()
p = re.compile(r'\d+\.\d+');
res = p.search(s);
if res:
gold = float(res.group())
if gold > 249.1 or gold < 223.2:
file = open('gold.txt', 'w')
file.write(str(gold)+'\n黄金价格提醒注意')
os.system('open -a Sublime\ Text\ 2 gold.txt')
pass
@jackyshan
Copy link
Author

10 14 * * 1-5 cd /Users/jackyshan/Desktop/Project/goldreminder/ && python /Users/jackyshan/Desktop/Project/goldreminder/goldreminder.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment