rabin hace 7 años
padre
commit
6550b0add8
Se han modificado 1 ficheros con 17 adiciones y 9 borrados
  1. 17 9
      service/ssgdfs.py

+ 17 - 9
service/ssgdfs.py

@@ -71,20 +71,24 @@ class Ssgdfs(object):
 			return True
 
 	def open(self):
-		self.display = Display(visible=0, size=(800, 600))
-		self.display.start()
-		#self.driver = webdriver.Remote(command_executor=Demeter.config['setting']['phantomjs'], desired_capabilities=DesiredCapabilities.PHANTOMJS)
-		self.driver = webdriver.Firefox()
+		#self.display = Display(visible=0, size=(800, 600))
+		#self.display.start()
+		self.driver = webdriver.Remote(command_executor=Demeter.config['setting']['phantomjs'], desired_capabilities=DesiredCapabilities.PHANTOMJS)
+		#options = webdriver.FirefoxOptions()
+		#options.add_argument('user-agent="Mozilla/5.0 (iPod; U; CPU iPhone OS 2_1 like Mac OS X; ja-jp) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F137 Safari/525.20"')
+		#self.driver = webdriver.Chrome(firefox_options=options)
 
 	def login(self):
-		self.driver.get(self.config['login_link'])
+		self.get(self.config['login_link'])
+		#source_code = self.driver.page_source
 		self.driver.find_element_by_id('login-id').send_keys(self.config['username'])
 		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)
 
 	def order(self, product):
-		self.driver.get(product)
+		#self.get('http://cn.ssgdfm.com/shop/common/cookieEnable?ce=null&returnUrl=%2Fshop%2Fproduct%2FproductDetail%3FprdtCode%3D05710004801')
+		self.get(product)
 		# 立刻购买
 		self.driver.execute_script('directOrderProduct()')
 		# 等待加载页面完成
@@ -138,8 +142,8 @@ class Ssgdfs(object):
 		self.driver.find_element_by_id('agree').click()
 		# 同意订购
 		self.driver.find_element_by_id('agree01').click()
-		# 选择支付方式:支付宝21 微信00
-		self.driver.find_element_by_xpath('//input[@id="pymntMeansCode" and @value="00"]').click()
+		# 选择支付方式:支付宝21 微信16
+		self.driver.find_element_by_xpath('//input[@id="pymntMeansCode" and @value="16"]').click()
 
 	def crop(self, order, id):
 		path = Demeter.path + 'runtime/upload/'
@@ -155,7 +159,11 @@ class Ssgdfs(object):
 	def wait(self, name):
 		WebDriverWait(self.driver, 100).until(lambda x: x.find_element_by_class_name(name).is_displayed())
 
+	def get(self, link):
+		self.driver.get(product)
+		self.driver.implicitly_wait(20)
+
 	def close(self):
 		self.driver.quit()
 		#self.driver.close()
-		self.display.stop()
+		#self.display.stop()