Browse Source

Fix Google login, move oil_market to function

JoostSijm 6 năm trước cách đây
mục cha
commit
503ff5a632
2 tập tin đã thay đổi với 7 bổ sung5 xóa
  1. 5 1
      app.py
  2. 2 4
      rival_regions_wrapper/client.py

+ 5 - 1
app.py

@@ -25,6 +25,7 @@ def login(credentials=None):
     action = input("Action: ")
     action_dict = {
         "market": market,
+        "oil_market": oil_market,
         "article": article
     }
 
@@ -33,7 +34,6 @@ def login(credentials=None):
 
 def market(client):
     """Get all market prices"""
-    # print(client.market_info('oil'))
     market_info = client.get_all_market_info()
     for i in market_info:
         print("")
@@ -42,6 +42,10 @@ def market(client):
         for j in market_info[i]:
             print(j.upper() + ':' + market_info[i][j])
 
+def oil_market(client):
+    """Get oil market price"""
+    print(client.market_info('oil'))
+
 def article(client):
     """Create article"""
     client.create_article("Test", "Whoops")

+ 2 - 4
rival_regions_wrapper/client.py

@@ -107,9 +107,10 @@ class Client:
         web.go_to(auth_text2[0])
         web.type(self.username, into='Email')
         web.click('Volgende')
-        time.sleep(5)
+        time.sleep(2)
         web.type(self.password, into='Password')
         web.click('Volgende')
+        time.sleep(2)
 
         web.click(css_selector=".sa_sn.float_left.imp.gogo")
         return web
@@ -145,12 +146,9 @@ class Client:
         """Set var_c"""
         LOGGER.info('set the var_c')
         response = self.session.get('http://rivalregions.com/#overview')
-        print(response.status_code)
         lines = response.text.split("\n")
-        print(lines)
         for line in lines:
             if re.match("(.*)var c_html(.*)", line):
-                print(line)
                 self.var_c = line.split("'")[-2]
                 return