Skip to content

Instantly share code, notes, and snippets.

@582033
Created December 6, 2016 02:34
Show Gist options
  • Save 582033/9752dddf9e62a9fa2f9b19fe81066627 to your computer and use it in GitHub Desktop.
Save 582033/9752dddf9e62a9fa2f9b19fe81066627 to your computer and use it in GitHub Desktop.
京东商品到货监控
import json, re, sys, os
from selenium import webdriver
class Sign:
def __init__(self, cid):
self.cid = cid
self.check()
#@site : sign_dict key
#@info : sign_dict value
def check(self):
dr = webdriver.PhantomJS()
dr.get('https://item.jd.com/%s.html' % self.cid)
html = dr.find_element_by_id('InitCartUrl').get_attribute('title').encode('utf-8')
html_len = len(html)
#print "%s - %s" % (html, html_len)
if html_len <= 0 :
tip = "商品到货了"
cmd = "terminal-notifier -message '%s'" % tip
os.system(cmd)
if __name__ == '__main__':
while True:
#sign = Sign('3594816')
sign = Sign('3594958')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment