Sfoglia il codice sorgente

Fix issue with accepting laws

JoostSijm 3 anni fa
parent
commit
cb62a95375
2 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 3 1
      app/api.py
  2. 1 1
      app/app.py

+ 3 - 1
app/api.py

@@ -49,6 +49,8 @@ def deep_explorate(state_id, region_id, resource_type, amount, alt):
         headers=HEADERS,
         params=params
     )
+    if response.status_code != 200:
+        LOGGER.warning('Error %s in response', response.status_code)
     soup = BeautifulSoup(response.text, 'html.parser')
     state_div = soup.find_all('div', {'class': 'index_case_50'})[1]
     action = state_div.findChild()['action']
@@ -81,7 +83,7 @@ def deep_explorate(state_id, region_id, resource_type, amount, alt):
     )
     soup = BeautifulSoup(response.text, 'html.parser')
     active_laws = soup.find('div', {'id': 'parliament_active_laws'})
-    for exploration_law in active_laws.findAll(text='Deep exploration,'):
+    for exploration_law in active_laws.findAll(text=re.compile('Deep exploration,')):
         action = exploration_law.parent.parent['action']
         action = action.replace('law', 'votelaw')
         result = requests.post(

+ 1 - 1
app/app.py

@@ -70,7 +70,7 @@ def start_deep_exploration(order_id):
             points,
             RESOURCE_IDS[order.resource_type]
         )
-        api.deep_explorate(state.id, order.region_id, order.resource_type, points, True)
+        api.deep_explorate(state.id, order.region_id, order.resource_type, points, False)
     time.sleep(10)
     schedule_order(order)