|
@@ -38,10 +38,12 @@ class Ssgdfs(object):
|
|
|
|
|
|
def buy(self, config):
|
|
|
product = Demeter.service('product')
|
|
|
+ self.num = 0
|
|
|
while 1:
|
|
|
state = self.check(config['link'])
|
|
|
if state == True:
|
|
|
try:
|
|
|
+ self.num = 0
|
|
|
print('get' + config['link'])
|
|
|
product.status(config['id'], 3)
|
|
|
|
|
@@ -59,7 +61,15 @@ class Ssgdfs(object):
|
|
|
product.status(config['id'], 2)
|
|
|
continue
|
|
|
else:
|
|
|
- gevent.sleep(30)
|
|
|
+ self.num = self.num + 1
|
|
|
+ self.close()
|
|
|
+ if self.num >= 10:
|
|
|
+ self.quit()
|
|
|
+ product.status(config['id'], 1)
|
|
|
+ print 'kill'
|
|
|
+ break
|
|
|
+ else:
|
|
|
+ gevent.sleep(30)
|
|
|
|
|
|
def check(self, product):
|
|
|
|
|
@@ -72,7 +82,6 @@ class Ssgdfs(object):
|
|
|
if string in data:
|
|
|
return True
|
|
|
else:
|
|
|
- self.close()
|
|
|
return False
|
|
|
|
|
|
def open(self):
|
|
@@ -100,6 +109,7 @@ class Ssgdfs(object):
|
|
|
self.driver.find_element_by_id('login-password').send_keys(self.config['password'])
|
|
|
self.driver.find_element_by_xpath('//input[@alt="login"]').click()
|
|
|
self.driver.implicitly_wait(5)
|
|
|
+ self.close()
|
|
|
|
|
|
def order(self, product):
|
|
|
|
|
@@ -180,7 +190,7 @@ class Ssgdfs(object):
|
|
|
self.driver.implicitly_wait(10)
|
|
|
|
|
|
def close(self):
|
|
|
- self.driver.quit()
|
|
|
+ self.driver.close()
|
|
|
|
|
|
|
|
|
|