Your Name 6 năm trước cách đây
mục cha
commit
52f7e38d3a

+ 239 - 253
hg3535/.idea/workspace.xml

@@ -3,11 +3,19 @@
   <component name="ChangeListManager">
     <list default="true" id="7fa42e97-ddea-4404-91db-5a9ccc162649" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/items.py" beforeDir="false" afterPath="$PROJECT_DIR$/items.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pipeline/ball_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/ball_func.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pipeline/bangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/bangqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pipeline/roll_wangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/roll_wangqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pipeline/roll_zuqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/roll_zuqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/pipeline/wangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/wangqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/pipeline/zuqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/zuqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/settings.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/spiders/roll_bangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/roll_bangqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/roll_lanqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/roll_lanqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/roll_wangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/roll_wangqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/zuqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/zuqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/utils/helper.py" beforeDir="false" afterPath="$PROJECT_DIR$/utils/helper.py" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
@@ -17,7 +25,7 @@
   </component>
   <component name="CoverageDataManager">
     <SUITE FILE_PATH="coverage/hg3535$items.coverage" NAME="items Coverage Results" MODIFIED="1554291398794" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
-    <SUITE FILE_PATH="coverage/hg3535$main.coverage" NAME="main Coverage Results" MODIFIED="1567167952696" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
+    <SUITE FILE_PATH="coverage/hg3535$main.coverage" NAME="main Coverage Results" MODIFIED="1567234053384" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
     <SUITE FILE_PATH="coverage/hg3535$hgjieshu.coverage" NAME="hgjieshu Coverage Results" MODIFIED="1558494720094" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/spiders" />
     <SUITE FILE_PATH="coverage/hg3535$halffull.coverage" NAME="halffull Coverage Results" MODIFIED="1554544334424" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/spiders" />
     <SUITE FILE_PATH="coverage/hg3535$pipelines.coverage" NAME="pipelines Coverage Results" MODIFIED="1554290866137" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
@@ -48,8 +56,8 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/main.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="340">
-              <caret line="17" column="52" lean-forward="true" selection-start-line="17" selection-start-column="52" selection-end-line="17" selection-end-column="52" />
+            <state relative-caret-position="320">
+              <caret line="16" column="45" lean-forward="true" selection-start-line="16" selection-start-column="45" selection-end-line="16" selection-end-column="45" />
               <folding>
                 <element signature="e#0#10#0" expanded="true" />
               </folding>
@@ -57,104 +65,23 @@
           </provider>
         </entry>
       </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/spiders/roll_bangqiu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="100">
-              <caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
-              <folding>
-                <element signature="e#46#61#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/settings.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="276">
-              <caret line="145" column="20" selection-start-line="145" selection-start-column="20" selection-end-line="145" selection-end-column="20" />
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/pipeline/roll_lanqiu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="29">
-              <caret line="255" column="56" lean-forward="true" selection-start-line="255" selection-start-column="56" selection-end-line="255" selection-end-column="56" />
-              <folding>
-                <element signature="e#0#15#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/pipeline/roll_bangqiu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="208">
-              <caret line="15" selection-start-line="15" selection-end-line="15" />
-              <folding>
-                <element signature="e#0#15#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
       <file pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/middlewares.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="248">
-              <caret line="134" selection-start-line="134" selection-end-line="134" />
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/pipeline/wangqiu.py">
+        <entry file="file://$PROJECT_DIR$/spiders/roll_lanqiu.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="-1611">
-              <caret line="117" column="43" selection-start-line="117" selection-start-column="43" selection-end-line="117" selection-end-column="43" />
+            <state relative-caret-position="397">
+              <caret line="670" column="59" selection-start-line="670" selection-start-column="59" selection-end-line="670" selection-end-column="59" />
               <folding>
-                <element signature="e#0#15#0" expanded="true" />
+                <element signature="e#24#39#0" expanded="true" />
               </folding>
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
+        <entry file="file://$PROJECT_DIR$/items.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="240">
-              <caret line="63" column="57" lean-forward="true" selection-start-line="63" selection-start-column="57" selection-end-line="63" selection-end-column="57" />
-              <folding>
-                <element signature="e#0#15#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/pipeline/roll_zuqiu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="409">
-              <caret line="67" column="75" selection-start-line="67" selection-start-column="47" selection-end-line="67" selection-end-column="75" />
-              <folding>
-                <element signature="e#18#33#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/spiders/zuqiu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="391">
-              <caret line="58" column="37" lean-forward="true" selection-start-line="58" selection-start-column="37" selection-end-line="58" selection-end-column="37" />
-              <folding>
-                <element signature="e#24#35#0" expanded="true" />
-              </folding>
+            <state relative-caret-position="278">
+              <caret line="372" column="11" selection-start-line="372" selection-start-column="4" selection-end-line="372" selection-end-column="14" />
             </state>
           </provider>
         </entry>
@@ -170,7 +97,6 @@
   </component>
   <component name="FindInProjectRecents">
     <findStrings>
-      <find>last_number</find>
       <find>total_goals</find>
       <find>2or7</find>
       <find>st_zq_league</find>
@@ -180,7 +106,6 @@
       <find>Zuqiustatus</find>
       <find>try</find>
       <find>&gt;=</find>
-      <find>Roll_Lanqiu</find>
       <find>psycopg2.extras</find>
       <find>pt</find>
       <find>Lanqiustatus</find>
@@ -198,8 +123,10 @@
       <find>settings.</find>
       <find>sq_dict</find>
       <find>网球</find>
-      <find>response_data</find>
       <find>datetime.datetime.now()</find>
+      <find>response_data</find>
+      <find>Roll_Wangqiu</find>
+      <find>Roll_Lanqiu</find>
     </findStrings>
     <replaceStrings>
       <replace>&quot;&quot;</replace>
@@ -253,8 +180,6 @@
   <component name="IdeDocumentHistory">
     <option name="CHANGED_PATHS">
       <list>
-        <option value="$PROJECT_DIR$/log/bangqiu.log" />
-        <option value="$PROJECT_DIR$/log/guanjun.log" />
         <option value="$PROJECT_DIR$/log/lanqiu.log" />
         <option value="$PROJECT_DIR$/log/liansai.log" />
         <option value="$PROJECT_DIR$/log/roll_zuqiu.log" />
@@ -273,7 +198,6 @@
         <option value="$PROJECT_DIR$/spiders/hg3535_zq_status_up.py" />
         <option value="$PROJECT_DIR$/spiders/hgjieshu.py" />
         <option value="$PROJECT_DIR$/spiders/hg3535_bangqiu.py" />
-        <option value="$PROJECT_DIR$/items.py" />
         <option value="$PROJECT_DIR$/spiders/hg3535_lanqiu.py" />
         <option value="$PROJECT_DIR$/spiders/wangqiu.py" />
         <option value="$PROJECT_DIR$/main_time.py" />
@@ -286,32 +210,35 @@
         <option value="$PROJECT_DIR$/spiders/zq_jieshu.py" />
         <option value="$PROJECT_DIR$/pipelines.py" />
         <option value="$PROJECT_DIR$/.gitignore" />
-        <option value="$PROJECT_DIR$/pipeline/ball_func.py" />
         <option value="$PROJECT_DIR$/pipeline/guanjun.py" />
         <option value="$PROJECT_DIR$/spiders/lanqiu.py" />
         <option value="$PROJECT_DIR$/spiders/guanjun.py" />
-        <option value="$PROJECT_DIR$/spiders/roll_wangqiu.py" />
-        <option value="$PROJECT_DIR$/pipeline/roll_wangqiu.py" />
-        <option value="$PROJECT_DIR$/utils/helper.py" />
-        <option value="$PROJECT_DIR$/spiders/zuqiu.py" />
         <option value="$PROJECT_DIR$/spiders/roll_zuqiu.py" />
-        <option value="$PROJECT_DIR$/pipeline/roll_zuqiu.py" />
         <option value="$PROJECT_DIR$/pipeline/lanqiu.py" />
         <option value="$PROJECT_DIR$/pipeline/roll_lanqiu.py" />
+        <option value="$PROJECT_DIR$/spiders/roll_bangqiu.py" />
+        <option value="$PROJECT_DIR$/pipeline/bangqiu.py" />
         <option value="$PROJECT_DIR$/pipeline/wangqiu.py" />
+        <option value="$PROJECT_DIR$/utils/helper.py" />
+        <option value="$PROJECT_DIR$/settings.py" />
+        <option value="$PROJECT_DIR$/pipeline/ball_func.py" />
+        <option value="$PROJECT_DIR$/pipeline/roll_zuqiu.py" />
+        <option value="$PROJECT_DIR$/pipeline/roll_bangqiu.py" />
+        <option value="$PROJECT_DIR$/spiders/roll_wangqiu.py" />
+        <option value="$PROJECT_DIR$/pipeline/roll_wangqiu.py" />
         <option value="$PROJECT_DIR$/pipeline/zuqiu.py" />
+        <option value="$PROJECT_DIR$/spiders/zuqiu.py" />
         <option value="$PROJECT_DIR$/main.py" />
-        <option value="$PROJECT_DIR$/spiders/roll_bangqiu.py" />
-        <option value="$PROJECT_DIR$/pipeline/roll_bangqiu.py" />
-        <option value="$PROJECT_DIR$/settings.py" />
+        <option value="$PROJECT_DIR$/items.py" />
+        <option value="$PROJECT_DIR$/spiders/roll_lanqiu.py" />
       </list>
     </option>
   </component>
   <component name="ProjectFrameBounds" extendedState="6">
-    <option name="x" value="-20" />
-    <option name="y" value="46" />
-    <option name="width" value="1936" />
-    <option name="height" value="1030" />
+    <option name="x" value="-88" />
+    <option name="y" value="96" />
+    <option name="width" value="1336" />
+    <option name="height" value="1017" />
   </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
   <component name="ProjectView">
@@ -336,6 +263,11 @@
               <item name="hg3535" type="462c0819:PsiDirectoryNode" />
               <item name="spiders" type="462c0819:PsiDirectoryNode" />
             </path>
+            <path>
+              <item name="hg3535" type="b2602c69:ProjectViewProjectNode" />
+              <item name="hg3535" type="462c0819:PsiDirectoryNode" />
+              <item name="utils" type="462c0819:PsiDirectoryNode" />
+            </path>
           </expand>
           <select />
         </subPane>
@@ -610,7 +542,7 @@
       <workItem from="1566976369645" duration="4000" />
       <workItem from="1566976385269" duration="13184000" />
       <workItem from="1566990066292" duration="35762000" />
-      <workItem from="1567126891838" duration="30250000" />
+      <workItem from="1567126891838" duration="52738000" />
     </task>
     <task id="LOCAL-00001" summary="修改后,版本二">
       <created>1555727493584</created>
@@ -836,11 +768,18 @@
       <option name="project" value="LOCAL" />
       <updated>1567157805401</updated>
     </task>
-    <option name="localTasksCounter" value="33" />
+    <task id="LOCAL-00033" summary="updata">
+      <created>1567167979453</created>
+      <option name="number" value="00033" />
+      <option name="presentableId" value="LOCAL-00033" />
+      <option name="project" value="LOCAL" />
+      <updated>1567167979453</updated>
+    </task>
+    <option name="localTasksCounter" value="34" />
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="1708924000" />
+    <option name="totallyTimeSpent" value="1731412000" />
   </component>
   <component name="TodoView">
     <todo-panel id="selected-file">
@@ -852,14 +791,15 @@
     </todo-panel>
   </component>
   <component name="ToolWindowManager">
-    <frame x="-8" y="-8" width="1936" height="1066" extended-state="6" />
+    <frame x="-88" y="96" width="1336" height="1017" extended-state="0" />
+    <editor active="true" />
     <layout>
-      <window_info content_ui="combo" id="Project" order="0" sideWeight="0.71173847" visible="true" weight="0.15831557" />
+      <window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.71173847" visible="true" weight="0.2507837" />
       <window_info id="Structure" order="1" sideWeight="0.2882615" side_tool="true" weight="0.1108742" />
       <window_info id="Favorites" order="2" sideWeight="0.5013405" side_tool="true" weight="0.108208954" />
       <window_info anchor="bottom" id="Message" order="0" />
       <window_info anchor="bottom" id="Find" order="1" weight="0.32832617" />
-      <window_info active="true" anchor="bottom" id="Debug" order="2" sideWeight="0.49946696" visible="true" weight="0.56008583" />
+      <window_info anchor="bottom" id="Debug" order="2" sideWeight="0.49946696" weight="0.32403433" />
       <window_info anchor="bottom" id="Cvs" order="3" weight="0.25" />
       <window_info anchor="bottom" id="Inspection" order="4" weight="0.4" />
       <window_info anchor="bottom" id="TODO" order="5" weight="0.32832617" />
@@ -869,7 +809,7 @@
       <window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50692964" side_tool="true" weight="0.38519314" />
       <window_info anchor="bottom" x="22" y="376" width="1876" height="298" id="Terminal" order="10" sideWeight="0.49307036" weight="0.3530043" />
       <window_info anchor="bottom" id="Python Console" order="11" sideWeight="0.49946696" weight="0.4356223" />
-      <window_info anchor="bottom" id="Run" order="12" sideWeight="0.87473345" weight="0.31223175" />
+      <window_info anchor="bottom" id="Run" order="12" sideWeight="0.87473345" visible="true" weight="0.33748585" />
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -983,11 +923,6 @@
           <line>84</line>
           <option name="timeStamp" value="4" />
         </line-breakpoint>
-        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
-          <url>file://$PROJECT_DIR$/pipeline/zuqiu.py</url>
-          <line>68</line>
-          <option name="timeStamp" value="29" />
-        </line-breakpoint>
         <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
           <url>file://$PROJECT_DIR$/spiders/roll_zuqiu.py</url>
           <line>34</line>
@@ -995,7 +930,7 @@
         </line-breakpoint>
         <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
           <url>file://$PROJECT_DIR$/pipeline/zuqiu.py</url>
-          <line>235</line>
+          <line>239</line>
           <option name="timeStamp" value="46" />
         </line-breakpoint>
         <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
@@ -1005,18 +940,68 @@
         </line-breakpoint>
         <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
           <url>file://$PROJECT_DIR$/spiders/zuqiu.py</url>
-          <line>352</line>
+          <line>355</line>
           <option name="timeStamp" value="55" />
         </line-breakpoint>
         <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
           <url>file://$PROJECT_DIR$/spiders/zuqiu.py</url>
-          <line>376</line>
+          <line>379</line>
           <option name="timeStamp" value="56" />
         </line-breakpoint>
         <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
           <url>file://$PROJECT_DIR$/pipeline/roll_bangqiu.py</url>
-          <line>15</line>
-          <option name="timeStamp" value="57" />
+          <line>93</line>
+          <option name="timeStamp" value="58" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/pipeline/zuqiu.py</url>
+          <line>262</line>
+          <option name="timeStamp" value="62" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/pipeline/zuqiu.py</url>
+          <line>196</line>
+          <option name="timeStamp" value="65" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/spiders/roll_wangqiu.py</url>
+          <line>280</line>
+          <option name="timeStamp" value="67" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/spiders/roll_wangqiu.py</url>
+          <line>61</line>
+          <option name="timeStamp" value="68" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/spiders/roll_wangqiu.py</url>
+          <line>62</line>
+          <option name="timeStamp" value="69" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/spiders/roll_wangqiu.py</url>
+          <line>285</line>
+          <option name="timeStamp" value="70" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/pipeline/roll_wangqiu.py</url>
+          <line>267</line>
+          <option name="timeStamp" value="71" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/spiders/zuqiu.py</url>
+          <line>341</line>
+          <option name="timeStamp" value="72" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/spiders/zuqiu.py</url>
+          <line>342</line>
+          <option name="timeStamp" value="73" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/spiders/zuqiu.py</url>
+          <line>366</line>
+          <option name="timeStamp" value="74" />
         </line-breakpoint>
       </breakpoints>
       <default-breakpoints>
@@ -1045,20 +1030,6 @@
     </expressions>
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/scrapy/utils/defer.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="151">
-          <caret line="62" selection-start-line="62" selection-end-line="62" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/twisted/internet/defer.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="11484">
-          <caret line="653" selection-start-line="653" selection-end-line="653" />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/twisted/python/failure.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="4158">
@@ -1111,13 +1082,6 @@
     <entry file="file://$PROJECT_DIR$/__init__.py">
       <provider selected="true" editor-type-id="text-editor" />
     </entry>
-    <entry file="file://$PROJECT_DIR$/items.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="1426">
-          <caret line="472" selection-start-line="472" selection-end-line="472" />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$PROJECT_DIR$/jianting.py">
       <provider selected="true" editor-type-id="text-editor" />
     </entry>
@@ -1163,34 +1127,6 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/wqbodan.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-1152" />
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/bangqiu.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-5382">
-          <folding>
-            <element signature="e#0#15#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/wangqiu.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-3024">
-          <caret line="14" column="20" selection-start-line="14" selection-start-column="20" selection-end-line="14" selection-end-column="20" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/pipelines.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="2797">
-          <caret line="1294" column="17" selection-start-line="1294" selection-start-column="17" selection-end-line="1294" selection-end-column="17" />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/aiohttp/client.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="166">
@@ -1219,16 +1155,6 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/roll_lanqiu.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="540">
-          <caret line="36" column="22" selection-start-line="36" selection-start-column="19" selection-end-line="36" selection-end-column="32" />
-          <folding>
-            <element signature="e#24#39#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/asyncio/tasks.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="145">
@@ -1243,16 +1169,6 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/roll_wangqiu.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="216">
-          <caret line="165" column="55" selection-start-line="165" selection-start-column="55" selection-end-line="165" selection-end-column="55" />
-          <folding>
-            <element signature="e#0#15#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
     <entry file="file://C:/venv/Lib/site-packages/twisted/internet/task.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="195">
@@ -1277,154 +1193,224 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/utils/helper.py">
+    <entry file="file://C:/venv/Lib/site-packages/twisted/internet/defer.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="235">
-          <caret line="27" selection-start-line="27" selection-end-line="27" />
+        <state relative-caret-position="-730">
+          <caret line="1611" selection-start-line="1611" selection-end-line="1611" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pipeline/lanqiu.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="2820">
+          <caret line="141" column="8" selection-start-line="140" selection-start-column="23" selection-end-line="140" selection-end-column="26" />
           <folding>
-            <element signature="e#0#14#0" expanded="true" />
+            <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://C:/venv/Lib/site-packages/twisted/internet/defer.py">
+    <entry file="file://$PROJECT_DIR$/middlewares.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-730">
-          <caret line="1611" selection-start-line="1611" selection-end-line="1611" />
+        <state relative-caret-position="308">
+          <caret line="137" selection-start-line="137" selection-end-line="137" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/ball_func.py">
+    <entry file="file://$PROJECT_DIR$/spiders/roll_bangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-23">
-          <caret line="24" selection-start-line="24" selection-end-line="24" />
+        <state relative-caret-position="100">
+          <caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
           <folding>
-            <element signature="e#0#15#0" expanded="true" />
+            <element signature="e#46#61#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/roll_zuqiu.py">
+    <entry file="file://$PROJECT_DIR$/spiders/wangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="1109">
-          <caret line="442" column="18" lean-forward="true" selection-start-line="442" selection-start-column="18" selection-end-line="442" selection-end-column="18" />
+        <state relative-caret-position="140">
+          <caret line="14" column="20" selection-start-line="14" selection-start-column="20" selection-end-line="14" selection-end-column="20" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://C:/venv/Lib/site-packages/pymongo/helpers.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="-1880">
+          <caret line="158" selection-start-line="158" selection-end-line="158" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pipelines.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="507">
+          <caret line="1294" column="17" selection-start-line="1294" selection-start-column="17" selection-end-line="1294" selection-end-column="17" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pipeline/bangqiu.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="1560">
+          <caret line="285" column="36" selection-start-line="284" selection-end-line="286" selection-end-column="41" />
           <folding>
-            <element signature="e#24#35#0" expanded="true" />
+            <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/lanqiu.py">
+    <entry file="file://$PROJECT_DIR$/settings.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="2820">
-          <caret line="141" column="8" selection-start-line="140" selection-start-column="23" selection-end-line="140" selection-end-column="26" />
+        <state relative-caret-position="296">
+          <caret line="146" lean-forward="true" selection-start-line="146" selection-end-line="146" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pipeline/ball_func.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="241">
+          <caret line="23" selection-start-line="23" selection-end-line="32" />
           <folding>
             <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/roll_wangqiu.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/roll_zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="469">
-          <caret line="337" column="22" lean-forward="true" selection-start-line="337" selection-start-column="22" selection-end-line="337" selection-end-column="22" />
+        <state relative-caret-position="441">
+          <caret line="538" selection-start-line="538" selection-end-line="538" selection-end-column="52" />
           <folding>
-            <element signature="e#24#39#0" expanded="true" />
+            <element signature="e#18#33#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/roll_lanqiu.py">
+    <entry file="file://$PROJECT_DIR$/spiders/wqbodan.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="29">
-          <caret line="255" column="56" lean-forward="true" selection-start-line="255" selection-start-column="56" selection-end-line="255" selection-end-column="56" />
+        <state relative-caret-position="-1665" />
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pipeline/wangqiu.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="443">
+          <caret line="256" column="59" lean-forward="true" selection-start-line="256" selection-start-column="59" selection-end-line="256" selection-end-column="59" />
           <folding>
             <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/roll_zuqiu.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/roll_bangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="409">
-          <caret line="67" column="75" selection-start-line="67" selection-start-column="47" selection-end-line="67" selection-end-column="75" />
+        <state relative-caret-position="260">
+          <caret line="22" column="28" lean-forward="true" selection-start-line="22" selection-start-column="28" selection-end-line="22" selection-end-column="28" />
           <folding>
-            <element signature="e#18#33#0" expanded="true" />
+            <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
+    <entry file="file://C:/venv/Lib/site-packages/redis/client.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="11652">
+          <caret line="1943" column="8" selection-start-line="1943" selection-start-column="8" selection-end-line="1943" selection-end-column="8" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/helper.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="240">
-          <caret line="63" column="57" lean-forward="true" selection-start-line="63" selection-start-column="57" selection-end-line="63" selection-end-column="57" />
+        <state relative-caret-position="245">
+          <caret line="13" selection-start-line="13" selection-end-line="13" />
           <folding>
-            <element signature="e#0#15#0" expanded="true" />
+            <element signature="e#0#14#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/spiders/zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="391">
-          <caret line="58" column="37" lean-forward="true" selection-start-line="58" selection-start-column="37" selection-end-line="58" selection-end-column="37" />
+        <state relative-caret-position="200">
+          <caret line="10" lean-forward="true" selection-start-line="10" selection-end-line="10" />
           <folding>
             <element signature="e#24#35#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/main.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/roll_lanqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="340">
-          <caret line="17" column="52" lean-forward="true" selection-start-line="17" selection-start-column="52" selection-end-line="17" selection-end-column="52" />
+        <state relative-caret-position="5500">
+          <caret line="287" column="9" selection-start-line="287" selection-start-column="8" selection-end-line="287" selection-end-column="50" />
           <folding>
-            <element signature="e#0#10#0" expanded="true" />
+            <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/roll_bangqiu.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="100">
-          <caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
+        <state relative-caret-position="-652">
+          <caret line="469" column="98" selection-start-line="469" selection-start-column="98" selection-end-line="469" selection-end-column="98" />
           <folding>
-            <element signature="e#46#61#0" expanded="true" />
+            <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/wangqiu.py">
+    <entry file="file://$PROJECT_DIR$/spiders/roll_wangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-1611">
-          <caret line="117" column="43" selection-start-line="117" selection-start-column="43" selection-end-line="117" selection-end-column="43" />
+        <state relative-caret-position="40">
+          <caret line="62" selection-start-line="62" selection-end-line="62" />
           <folding>
-            <element signature="e#0#15#0" expanded="true" />
+            <element signature="e#24#39#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/settings.py">
+    <entry file="file://$PROJECT_DIR$/spiders/roll_zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="276">
-          <caret line="145" column="20" selection-start-line="145" selection-start-column="20" selection-end-line="145" selection-end-column="20" />
+        <state relative-caret-position="8155">
+          <caret line="442" column="18" lean-forward="true" selection-start-line="442" selection-start-column="18" selection-end-line="442" selection-end-column="18" />
+          <folding>
+            <element signature="e#24#35#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/roll_bangqiu.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/roll_wangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="208">
-          <caret line="15" selection-start-line="15" selection-end-line="15" />
+        <state relative-caret-position="4666">
+          <caret line="270" selection-start-line="270" selection-end-line="270" />
           <folding>
             <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/middlewares.py">
+    <entry file="file://$PROJECT_DIR$/main.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="320">
+          <caret line="16" column="45" lean-forward="true" selection-start-line="16" selection-start-column="45" selection-end-line="16" selection-end-column="45" />
+          <folding>
+            <element signature="e#0#10#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/items.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="248">
-          <caret line="134" selection-start-line="134" selection-end-line="134" />
+        <state relative-caret-position="278">
+          <caret line="372" column="11" selection-start-line="372" selection-start-column="4" selection-end-line="372" selection-end-column="14" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/spiders/roll_lanqiu.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="397">
+          <caret line="670" column="59" selection-start-line="670" selection-start-column="59" selection-end-line="670" selection-end-column="59" />
+          <folding>
+            <element signature="e#24#39#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>

+ 2 - 0
hg3535/items.py

@@ -370,6 +370,7 @@ class Roll_Lanqiu(scrapy.Field):
     capot = scrapy.Field()
     team_score = scrapy.Field()
     team_score_rule = scrapy.Field()
+    score_dict = scrapy.Field()
 
 
 class Roll_Wangqiu(scrapy.Field):
@@ -403,6 +404,7 @@ class Roll_Wangqiu(scrapy.Field):
     # 每局比分
     score_dict = scrapy.Field()
     pt = scrapy.Field()
+    rule = scrapy.Field()
 
     concedes_dict = scrapy.Field()
     concedes_dict_rule = scrapy.Field()

+ 2 - 2
hg3535/main.py

@@ -12,9 +12,9 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
 # execute(["scrapy", "crawl", "wqbodan"])
 # execute(["scrapy", "crawl", "bangqiu"])
 # execute(["scrapy", "crawl", "roll_zuqiu"]) # 滚球足球 回来要解开这个注释 其他全部解封
-# execute(["scrapy", "crawl", "roll_lanqiu"]) #滚球篮球
+execute(["scrapy", "crawl", "roll_lanqiu"]) #滚球篮球
 # execute(["scrapy", "crawl", "roll_wangqiu"]) #滚球网球
-execute(["scrapy", "crawl", "roll_bangqiu"])  # 滚球棒球
+# execute(["scrapy", "crawl", "roll_bangqiu"])  # 滚球棒球
 # execute(["scrapy", "crawl", "ball_status"]) #滚球id本地存
 # execute(["scrapy", "crawl", "ball_status_update"]) #滚球id结束时间更新状态
 # execute(["scrapy", "crawl", "zq_jieshu"]) #滚球id结束时间更新状态

+ 19 - 19
hg3535/pipeline/ball_func.py

@@ -32,23 +32,23 @@ def fuhao(f):
         return f
 
 
-def get_pcode(corner_ball, code):
-    code_dict = {'concede': 1, 'capot': 2, 'two_sides': 3, 'total_goal': 4, 'half_full': 5, 'bodan': 6,
-                 'first_last_ball': 7, 'tema_ball': 11, 'goal_size': 13}
-    if corner_ball:
-        if corner_ball == "角球":
-            p_code = "corner_ball"
-            p_id = 9
-        elif corner_ball == "会晋级":
-            p_code = "promotion"
-            p_id = 10
-        elif corner_ball == "罚牌数":
-            p_code = "Penalty_card"
-            p_id = 12
-        else:
-            p_code = code
-            p_id = code_dict[code]
-        return p_code, p_id
-    else:
-        return code, code_dict[code]
+# def get_pcode(corner_ball, code):
+#     code_dict = {'concede': 1, 'capot': 2, 'two_sides': 3, 'total_goal': 4, 'half_full': 5, 'bodan': 6,
+#                  'first_last_ball': 7, 'tema_ball': 11, 'goal_size': 13}
+#     if corner_ball:
+#         if corner_ball == "角球":
+#             p_code = "corner_ball"
+#             p_id = 9
+#         elif corner_ball == "会晋级":
+#             p_code = "promotion"
+#             p_id = 10
+#         elif corner_ball == "罚牌数":
+#             p_code = "Penalty_card"
+#             p_id = 12
+#         else:
+#             p_code = code
+#             p_id = code_dict[code]
+#         return p_code, p_id
+#     else:
+#         return code, code_dict[code]
 

+ 99 - 150
hg3535/pipeline/bangqiu.py

@@ -2,23 +2,34 @@ import datetime
 import pymongo
 import time
 import logging
+
+from twisted.internet import defer, reactor
+
 from .ball_func import fuhao
 from ..utils.helper import Helper
-from .ball_func import get_pcode, new_time, out_time
-from concurrent.futures import ThreadPoolExecutor
-from requests_futures.sessions import FuturesSession
+from .ball_func import new_time
+from ..settings import M_HOST, M_USER, M_PASSWORD, M_POST, M_DB, LEAGUE_URL, ODDS_URL, MATCH_URL, MATCH_RESULT
 
 
 class Bangqiupipeline(object):
+
     def open_spider(self, spider):
-        self.mongo = pymongo.MongoClient(host="192.168.2.200", username="kaiyou", password="kaiyou", port=27017)
-        self.db = self.mongo['kaiyou']
-        self.session = FuturesSession(executor=ThreadPoolExecutor(max_workers=10))
 
+        self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST,
+                                         authSource='kaiyou')
+        self.db = self.mongo[M_DB]
+
+    @defer.inlineCallbacks
     def process_item(self, item, spider):
-        # print(item)
+        out = defer.Deferred()
+        reactor.callInThread(self._do_calculation, item, out)
+        yield out
+        defer.returnValue(item)
+
+    def _do_calculation(self, item, out):
+
+    # def process_item(self, item, spider):
         logger = logging.getLogger(__name__)
-        url = 'http://admin.5gogo.com'
         # logger.warning(query.addErrback(self.handle_error, item, spider))
         # 联赛id
         league_id = item['league_id']
@@ -42,8 +53,6 @@ class Bangqiupipeline(object):
             month = str(data_game[1].strip())
             day = str(data_game[0])
         except Exception as e:
-            # logger.warning('data_game字段分割错误')
-            # logger.warning(e)
             data_game = item['data_game'].split(" ")
             months = str(data_game[1].strip())
             month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07',
@@ -66,7 +75,7 @@ class Bangqiupipeline(object):
         jijie = item['jijie']
         # 球队得分
         qiudui = item['qiudui']
-        pt = item['pt']
+        pt = str(item['pt'])
         # 让球
         concedes_dict = item['concedes_dict']
         concedes_dict_rule = item['concedes_dict_rule']
@@ -95,163 +104,101 @@ class Bangqiupipeline(object):
         bangqiu = item['bangqiu']
         match_date, match_time, time3 = new_time(ctime)
         us_time = ctime
-        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+        uuid = Helper.genearte_uuid(league_name + 'hg3535')
         """联赛表"""
-        last_time = '2019-12-31 23:59:59'
-        league_dict = {"game_code": "bq", "title": "league", "source": "hg3535"}
-        league_list = []
+        last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
 
-        league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
-        league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
-        league_data = dict(zip(league_key, league_value))
-        league_list.append(league_data)
-        league_dict['data'] = league_list
         # print(league_list)
         # print(league_dict)
-        if self.db.hg3535_bq_league.find({'lg_id': league_id}).count() < 1:
-            res = Helper.async_post(url + '/setLeague', league_dict)
-            print(res)
-            self.db.hg3535_bq_league.insert(league_list)
-
-        """插入赛事表"""
-        competition = self.db.hg3535_bq_competition.find_one({"match_id": str(match_id)})
-        match_list = []
-        if competition:
-            print('赛事已存在,修改赛事四状态')
-            is_morningplate = competition['is_morningplate']
-            is_rollball = competition['is_rollball']
-            is_stringscene = competition['is_stringscene']
-            is_today = competition['is_today']
-            lmtime = competition['match_time']
-            if pt == 3:
-                if is_stringscene != 1 or lmtime != match_time:
-                    match_dict = {"game_code": "bq", "title": "match", "source": "hg3535"}
-                    match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                                 "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                                 "half_match_id", "is_today"]
-                    match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
-                                   "hg3535", is_rollball, is_morningplate, 1, us_time, uuid, 0, is_today]
-                    match_data = dict(zip(match_key, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_bq_competition.update({'match_id': match_id},
-                                                         {"$set": {"is_stringscene": 1, 'match_time': match_time}},
-                                                         upsert=True)
-            if pt == 2:
-                if is_morningplate != 1 or lmtime != match_time:
-                    match_dict = {"game_code": "bq", "title": "match", "source": "hg3535"}
-                    match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                                 "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                                 "half_match_id", "is_today"]
-                    match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
-                                   "hg3535", is_rollball, 1, is_stringscene, us_time, uuid, 0, is_today]
-                    match_data = dict(zip(match_key, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_bq_competition.update({'match_id': match_id},
-                                                         {"$set": {"is_morningplate": 1, 'match_time': match_time}},
-                                                         upsert=True)
-            if pt == 1:
-                if is_today != 1 or lmtime != match_time:
-                    match_dict = {"game_code": "bq", "title": "match", "source": "hg3535"}
-                    match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                                 "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                                 "half_match_id", "is_today"]
-                    match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
-                                   "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, 1]
-                    match_data = dict(zip(match_kay, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_bq_competition.update({'match_id': match_id},
-                                                         {"$set": {"is_today": 1, 'match_time': match_time}},
-                                                         upsert=True)
+        if self.db.bq_league35.find({'lg_id': league_id}).count() < 1:
+            league_dict = {"game_code": "bq", "title": "league", "source": "hg3535"}
+            league_list = []
+            league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
+            league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
+            league_data = dict(zip(league_key, league_value))
+            league_list.append(league_data)
+            league_dict['data'] = league_list
+            res = Helper.async_post(LEAGUE_URL, league_dict)
+            if '成功' in res:
+                self.db.bq_league35.insert(league_data)
+                logger.info('棒球联赛提交成功, {}'.format(res))
             else:
-                print("赛事已存在,赛事状态时间未改变,不做修改")
+                logger.warning('棒球联赛提交失败, {}'.format(res))
+                logger.warning(league_dict)
+
+        pt_dict = {'1': 'is_today', '2': 'is_morningplate', '3': 'is_stringscene', '4': 'is_rollball'}
+        pt_status = pt_dict[pt]
+        if pt == '3':
+            is_rollball = 0
+            is_today = 0
+            is_morningplate = 0
+            is_stringscene = 1
+        elif pt == '2':
+            is_rollball = 0
+            is_today = 0
+            is_morningplate = 1
+            is_stringscene = 0
         else:
-            print('赛事不存在, 插入新数据')
-            if pt == 3:
-                is_rollball = 0
-                is_today = 0
-                is_morningplate = 0
-                is_stringscene = 1
-            elif pt == 2:
-                is_rollball = 0
-                is_today = 0
-                is_morningplate = 1
-                is_stringscene = 0
-            else:
-                is_today = 1
-                is_rollball = 0
-                is_morningplate = 0
-                is_stringscene = 0
+            is_today = 1
+            is_rollball = 0
+            is_morningplate = 0
+            is_stringscene = 0
+        """插入赛事表"""
+        if self.db.bq_competition35.find({"match_id": match_id, pt_status: 1}).count() < 1:
+            match_list = []
+
             match_dict = {"game_code": "bq", "title": "match", "source": "hg3535"}
-            match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time", "tag",
-                         "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
+            match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
+                         "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
                          "half_match_id", "is_today"]
-            match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number, "hg3535",
-                           is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today]
-            match_data = dict(zip(match_kay, match_value))
+            match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
+                           "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today]
+            match_data = dict(zip(match_key, match_value))
             match_list.append(match_data)
             match_dict['data'] = match_list
-            res = Helper.async_post(url + '/setMatch', match_dict)
-            print(res)
-            self.db.hg3535_bq_competition.insert(match_list)
+            res = Helper.async_post(MATCH_URL, match_dict)
+            if '成功' in res:
+                self.db.bq_competition35.insert(match_data)
+                logger.info('棒球赛事提交成功, {}'.format(res))
+            else:
+                logger.warning('棒球赛事提交失败, {}'.format(res))
+                logger.warning(match_data)
+        else:
+            logger.info("棒球赛事已存在,不做修改")
 
         """赔率"""
-        try:
-            result = self.db.hg3535_bq_odds.find_one({'match_id': str(match_id), 'pt': pt})
-            odds_only_list = result['odds_only']
-        except:
-            result = ''
-            odds_only_list = []
         data_list = []
         odds_onlys = []
         # 让球
         if concedes_dict:
             for key, value in concedes_dict.items():
                 sole_str = 'CO' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'CO' + str(key) + str(match_id) + 'hg3535' + str(concedes_dict_rule[key]) + str(
                     value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(str(concedes_dict_rule[key]))
                 concedes_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                                      "odds_only", "sole", "source", "type", "team"]
                 concedes_dict_value = [match_id, league_id, key, '0', 0, 'CO', value, condition,
                                        odds_only, sole, 'hg3535', '0', '']
                 concedes_dict_data = dict(zip(concedes_dict_key, concedes_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(concedes_dict_data)
+                data_list.append(concedes_dict_data)
         # 总得分大/小
         if total_size_dict:
             for key, value in total_size_dict.items():
                 sole_str = 'TN' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'TN' + str(key) + str(match_id) + 'hg3535' + str(
                     total_size_dict_rule[key]) + str(value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(str(total_size_dict_rule[key]))
                 total_size_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                        "condition", "odds_only", "sole", "source", "type", "team"]
                 total_size_dict_value = [match_id, league_id, key, '0', 0, 'TN', value, condition,
                                          odds_only, sole, 'hg3535', '0', '']
                 total_size_dict_data = dict(zip(total_size_dict_key, total_size_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(total_size_dict_data)
+                data_list.append(total_size_dict_data)
         # 球队得分大/小 主队
         # if team_score_home_dict:
         #     for key, value in team_score_home_dict.items():
@@ -290,37 +237,33 @@ class Bangqiupipeline(object):
         if capots_dict:
             for key, value in capots_dict.items():
                 sole_str = 'C' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'C' + str(key) + str(match_id) + 'hg3535' + str(value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 capots_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                    "condition", "odds_only", "sole", "source", "type", "team"]
                 capots_dict_value = [match_id, league_id, key, '0', 0, 'C', value, '',
                                      odds_only, sole, 'hg3535', '0', '']
                 capots_dict_data = dict(zip(capots_dict_key, capots_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(capots_dict_data)
+                data_list.append(capots_dict_data)
         # 总得分单双
         if odd_evens_dict:
             for key, value in odd_evens_dict.items():
                 sole_str = 'TS' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'TS' + str(key) + str(match_id) + 'hg3535' + str(
                     odd_evens_dict_rule[key]) + str(value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(str(odd_evens_dict_rule[key]))
                 odd_evens_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                       "condition", "odds_only", "sole", "source", "type", "team"]
                 odd_evens_dict_value = [match_id, league_id, key, '0', 0, 'TS', value, condition,
                                         odds_only, sole, 'hg3535', '0', '']
                 odd_evens_dict_data = dict(zip(odd_evens_dict_key, odd_evens_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(odd_evens_dict_data)
+                data_list.append(odd_evens_dict_data)
         # 让球 前五局
         # 总得分大/小 前五局
-        if pt == 3:
+        if pt == '3':
             ris_stringscene = 1
         else:
             ris_stringscene = 0
@@ -329,14 +272,20 @@ class Bangqiupipeline(object):
         odds_value = ["bq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid,
                       ris_stringscene, utime, pt]
         odds_dict = dict(zip(odds_key, odds_value))
-        # print(odds_dict)
-        # print(123)
+
         if data_list:
-            res = Helper.async_post(url + '/setOdds', odds_dict)
-            print(res)
-            if '成功' in res:
-                if result:
-                    self.db.hg3535_bq_odds.update({'match_id': match_id, 'pt': pt}, {
-                        '$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
+            res = Helper.async_post(ODDS_URL, odds_dict)
+            if res:
+                if "成功" in res:
+                    logger.info('棒球赔率提交成功, {}'.format(res))
+                    logger.info(odds_dict)
                 else:
-                    self.db.hg3535_bq_odds.insert(odds_dict)
+                    logger.warning('棒球赔率提交失败, {}'.format(res))
+                    logger.warning(odds_dict)
+            else:
+                logger.warning('详细接口赔率返回异常, {}'.format(res))
+                logger.warning(odds_dict)
+        else:
+            logger.info('棒球详细赔率列表为空, 不提交')
+
+        reactor.callFromThread(out.callback, item)

+ 241 - 0
hg3535/pipeline/roll_bangqiu.py

@@ -0,0 +1,241 @@
+import datetime
+import pymongo
+import time
+import logging
+# import json
+
+from twisted.internet import defer, reactor
+
+from .ball_func import fuhao
+from ..utils.helper import Helper
+# from .ball_func import get_pcode, new_time, out_time
+# from concurrent.futures import ThreadPoolExecutor
+# from requests_futures.sessions import FuturesSession
+from ..settings import M_HOST, M_USER, M_PASSWORD, M_POST, M_DB, LEAGUE_URL, ODDS_URL, MATCH_URL, MATCH_RESULT
+
+
+class Roll_Banqiupipeline(object):
+    def open_spider(self, spider):
+        self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST, authSource='kaiyou')
+        self.db = self.mongo[M_DB]
+
+    # @defer.inlineCallbacks
+    def process_item(self, item, spider):
+    #     out = defer.Deferred()
+    #     reactor.callInThread(self._do_calculation, item, out)
+    #     yield out
+    #     defer.returnValue(item)
+    #
+    # def _do_calculation(self, item, out):
+        # 使用twisted将mysql插入变成异步执行
+        logger = logging.getLogger(__name__)
+        # 联赛id
+        # url = 'http://admin.5gogo.com'
+        # roll_bq = []
+        league_id = item['league_id']
+        # 联赛名
+        league_name = item['league_name']
+        # result = item['result']
+        # 比赛id
+        match_id = item['game_id']
+        # 球队1
+        team_home = item['team_home']
+        # 球队2
+        team_guest = item['team_guest']
+        # 数量(97>)
+        tag_number = item['number']
+        # 新增 match_score_dict
+        match_score_dict = item['match_score_dict']
+        # 比赛状态
+        zhuangtai = item['zhuangtai']
+        # 日期
+        # data_game = item['data_game']
+        data_game = item['data_game'].split("/")
+        month = str(data_game[1].strip())
+        day = str(data_game[0])
+        # 比赛时间
+        time_game = str(item['time_game'])
+        # 比赛时间,时间戳
+        ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00".strip()
+        r_ctime = "2019" + "-" + month + "-" + day
+        # 现在时间,时间戳
+        utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
+        match_date = datetime.datetime.now().strftime("%Y-%m-%d")
+        # expire_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + 60))
+        # 队1分数
+        score_home = item['score_home']
+        # 队2分数
+        score_guest = item['score_guest']
+        # 第几节
+        jijie = item['jijie']
+        # 球队得分
+        qiudui = item['qiudui']
+        pt = 4
+        # 滚球这个位置获取不到这些字段
+        # match_date, match_time = new_time(ctime)
+        # 让球
+        concedes_dict = item['concedes_dict']
+        concedes_dict_rule = item['concedes_dict_rule']
+        # 独赢
+        capots_dict = item['capots_dict']
+        # 总得分大小
+        total_size_dict = item['total_size_dict']
+        total_size_dict_rule = item['total_size_dict_rule']
+        # 总得分单双
+        odd_evens_dict = item['odd_evens_dict']
+        odd_evens_dict_rule = item['odd_evens_dict_rule']
+        # 赛事失效时间
+        # new_match_score_dict = json.dumps(match_score_dict)
+        # 具体比分
+        team_source_dict = item['team_source_dict']
+        uuid = Helper.genearte_uuid(league_name + 'hg3535')
+        """联赛"""
+        last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
+        if self.db.bq_league35.find({'lg_id': league_id}).count() < 1:
+            league_dict = {"game_code": "bq", "title": "league", "source": "hg3535"}
+            league_list = []
+            league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
+            league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
+            league_data = dict(zip(league_key, league_value))
+            league_list.append(league_data)
+            league_dict['data'] = league_list
+            res = Helper.async_post(LEAGUE_URL, league_dict)
+            if '成功' in res:
+                self.db.bq_league35.insert(league_data)
+                logger.info('棒球滚球联赛提交成功, {}'.format(res))
+            else:
+                logger.warning('棒球滚球联赛提交失败, {}'.format(res))
+                logger.warning(league_dict)
+        """赛事"""
+        if self.db.bq_competition35.find({"match_id": match_id, 'is_rollball': 1}).count() < 1:
+            match_list = []
+            match_dict = {"game_code": "bq", "title": "match", "source": "hg3535"}
+            match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
+                         "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
+                         "half_match_id", "is_today"]
+            match_value = [team_home, team_guest, league_id, 1, match_id, match_date, '00:00', tag_number,
+                           "hg3535", 1, 0, 0, utime, uuid, 0, 0]
+            match_data = dict(zip(match_key, match_value))
+            match_list.append(match_data)
+            match_dict['data'] = match_list
+            res = Helper.async_post(MATCH_URL, match_dict)
+            if '成功' in res:
+                self.db.hg3535_bq_competition.insert(match_data)
+            else:
+                logger.warning('棒球滚球赛事提交失败, {}'.format(res))
+                logger.warning(match_data)
+        else:
+            logger.info("棒球赛事已存在,棒球赛事状态时间未改变,不做修改")
+        """赔率"""
+        data_list = []
+        odds_onlys = []
+        # 让球
+        if concedes_dict:
+            for key, value in concedes_dict.items():
+                if value:
+                    sole_str = 'CO' + str(key) + '0' + str(match_id) + 'hg3535'
+                    sole = Helper.genearte_MD5(sole_str, pt)
+                    odds_str = 'CO' + str(key) + '0' + str(concedes_dict_rule[key]) + str(
+                        value) + 'hg3535' + str(match_id)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
+                    condition = fuhao(concedes_dict_rule[key])
+                    concedes_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                    "condition", "odds_only", "sole", "source", "type", "team"]
+                    concedes_value = [match_id, league_id, key, "0", 0, 'CO', value, condition,
+                                      odds_only, sole, "hg3535", "0", ""]
+                    concedes_data = dict(zip(concedes_key, concedes_value))
+                    data_list.append(concedes_data)
+        # 独赢
+        if capots_dict:
+            for key, value in capots_dict.items():
+                if value:
+                    sole_str = 'C' + str(key) + '0' + str(match_id) + 'hg3535'
+                    sole = Helper.genearte_MD5(sole_str, pt)
+                    odds_str = 'C' + str(key) + '0' + '0' + str(value) + 'hg3535' + str(match_id)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
+                    capots_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                  "condition", "odds_only", "sole", "source", "type", "team"]
+                    capots_value = [match_id, league_id, key, "0", 0, 'C', value, '',
+                                    odds_only, sole, "hg3535", "0", ""]
+                    capots_data = dict(zip(capots_key, capots_value))
+                    data_list.append(capots_data)
+        # 总得分大小
+        if total_size_dict:
+            for key, value in total_size_dict.items():
+                if value:
+                    sole_str = 'TN' + str(key) + '0' + str(match_id) + 'hg3535'
+                    sole = Helper.genearte_MD5(sole_str, pt)
+                    odds_str = 'TN' + str(key) + '0' + str(total_size_dict_rule[key]) + str(
+                        value) + 'hg3535' + str(match_id)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
+                    condition = fuhao(total_size_dict_rule[key])
+                    total_size_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                      "condition", "odds_only", "sole", "source", "type", "team"]
+                    total_size_value = [match_id, league_id, key, "0", 0, 'TN', value, condition,
+                                        odds_only, sole, "hg3535", "0", ""]
+                    total_size_data = dict(zip(total_size_key, total_size_value))
+                    data_list.append(total_size_data)
+        # 总得分单双
+        if odd_evens_dict:
+            for key, value in odd_evens_dict.items():
+                sole_str = 'TS' + str(key) + '0' + str(match_id) + 'hg3535'
+                sole = Helper.genearte_MD5(sole_str, pt)
+                odds_str = 'TS' + str(key) + '0' + str(odd_evens_dict_rule[key]) + str(value) + 'hg3535' + str(
+                    match_id)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
+                condition = fuhao(odd_evens_dict_rule[key])
+                odd_evens_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                 "condition", "odds_only", "sole", "source", "type", "team"]
+                odd_evens_value = [match_id, league_id, key, "0", 0, 'TS', value, condition,
+                                   odds_only, sole, "hg3535", "0", ""]
+                odd_evens_data = dict(zip(odd_evens_key, odd_evens_value))
+                data_list.append(odd_evens_data)
+        odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
+                    "is_stringscene", "utime", "pt"]
+        odds_value = ["bq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid,
+                      0, utime, pt]
+        odds_dict = dict(zip(odds_key, odds_value))
+        if data_list:
+            res = Helper.async_post(ODDS_URL, odds_dict)
+            if "成功" in res:
+                logger.info('棒球滚球赔率提交成功, {}'.format(res))
+                logger.info(odds_dict)
+            else:
+                logger.warning('棒球滚球赔率提交失败, {}'.format(res))
+                logger.warning(odds_dict)
+        else:
+            logger.info('棒球滚球详细赔率列表为空, 不提交')
+        """赛事结果"""
+        da_list = []
+        bq_rball = {
+            "lg_id": league_id, "home_team": team_home, "guest_team": team_guest, "home_rate": '', "guest_rate": '',
+            "home_score": score_home, "guest_score": score_guest, "status": 1, "first_score": '',
+            "last_score": '', "all_inning": team_source_dict['total_inning'],
+            "match_score": team_source_dict['total_source'], "match_winer": '', "updata_time": '',
+            "match_time": time_game, "match_process": jijie,
+            "tag": tag_number, "match_id": match_id, "source": 'hg3535',
+            "ctime": ctime, "uuid": uuid, "result_mark": qiudui, "start_time": '', 'warn_more': '',
+        }
+        da_list.append(bq_rball)
+        r_data_dict = {
+            "game_code": "bq",
+            "title": "match_result_r",
+            "source": "hg3535",
+            "data": da_list,
+        }
+        # print(r_data_dict)
+        if da_list:
+            try:
+                res = Helper.async_post(MATCH_RESULT, r_data_dict)
+                if "成功" in res:
+                    logger.info('棒球滚球结果记录提交成功, {}'.format(res))
+                    logger.info(odds_dict)
+                else:
+                    logger.warning('棒球滚球结果记录提交失败, {}'.format(res))
+                    logger.warning(odds_dict)
+            except Exception as e:
+                logger.warning("滚球接口数据异常, 提交失败, {}".format(e))
+        else:
+            logger.info('棒球滚球结果记录为空, 不提交')
+        # reactor.callFromThread(out.callback, item)
+

+ 2 - 1
hg3535/pipeline/roll_lanqiu.py

@@ -47,6 +47,7 @@ class Roll_Lanqiupipeline(object):
         zhuangtai = item['zhuangtai']
         # 日期
         # data_game = item['data_game']
+        result_mark = item['score_dict']
         try:
             data_game = item['data_game'].split("/")
             month = str(data_game[1].strip())
@@ -266,7 +267,7 @@ class Roll_Lanqiupipeline(object):
                     "guest_score": score_guest, "all_goal": "", "status": 1,
                     "first_score": "", "last_score": "", "match_score": match_score, "uuid": uuid,
                     "match_winer": "", "match_time": time_game, "u_home_score": "", "u_guest_score": "",
-                    "match_process": jijie, "tag": number, "result_mark": '',
+                    "match_process": jijie, "tag": number, "result_mark": result_mark,
                     "match_id": match_id, "p_code": ""}
         data_list.append(lq_rball)
         r_data_dict = {

+ 104 - 120
hg3535/pipeline/roll_wangqiu.py

@@ -5,19 +5,27 @@ import logging
 import json
 from .ball_func import fuhao
 from ..utils.helper import Helper
-from .ball_func import get_pcode, new_time, out_time
-from concurrent.futures import ThreadPoolExecutor
-from requests_futures.sessions import FuturesSession
-
+# from .ball_func import get_pcode, new_time, out_time
+# from concurrent.futures import ThreadPoolExecutor
+# from requests_futures.sessions import FuturesSession
+from ..settings import M_HOST, M_USER, M_PASSWORD, M_POST, M_DB, LEAGUE_URL, ODDS_URL, MATCH_URL, MATCH_RESULT
+from twisted.internet import defer, reactor
 
 class Roll_Wangqiupipeline(object):
     def open_spider(self, spider):
-        self.mongo = pymongo.MongoClient(host="192.168.2.200", username="kaiyou", password="kaiyou", port=27017)
-        self.db = self.mongo['kaiyou']
-        self.session = FuturesSession(executor=ThreadPoolExecutor(max_workers=10))
+        self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST,
+                                         authSource='kaiyou')
+        self.db = self.mongo[M_DB]
 
+    # @defer.inlineCallbacks
+    # def process_item(self, item, spider):
+    #     out = defer.Deferred()
+    #     reactor.callInThread(self._do_calculation, item, out)
+    #     yield out
+    #     defer.returnValue(item)
+    #
+    # def _do_calculation(self, item, out):
     def process_item(self, item, spider):
-        url = 'http://admin.5gogo.com'
         logger = logging.getLogger(__name__)
         # 联赛id
         league_id = item['league_id']
@@ -36,25 +44,27 @@ class Roll_Wangqiupipeline(object):
         zhuangtai = item['zhuangtai']
         # 日期
         # data_game = item['data_game']
-        try:
-            data_game = item['data_game'].split("/")
-            month = str(data_game[1].strip())
-            day = str(data_game[0])
-        except Exception as e:
-            logger.warning(e)
-            data_game = item['data_game'].split(" ")
-            months = str(data_game[1].strip())
-            month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07',
-                          'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
-            month = month_dict[months]
-            day = str(data_game[0])
+        rule = item['rule']
+        # try:
+        #     data_game = item['data_game'].split("/")
+        #     month = str(data_game[1].strip())
+        #     day = str(data_game[0])
+        # except Exception as e:
+        #     logger.warning(e)
+        #     data_game = item['data_game'].split(" ")
+        #     months = str(data_game[1].strip())
+        #     month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07',
+        #                   'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
+        #     month = month_dict[months]
+        #     day = str(data_game[0])
         # 比赛时间
         time_game = str(item['time_game'])
         # 比赛时间,时间戳
-        ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
-        r_ctime = "2019" + "-" + month + "-" + day
+        # ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
+        # r_ctime = "2019" + "-" + month + "-" + day
         # 现在时间,时间戳
         utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
+        match_date = datetime.datetime.now().strftime("%Y-%m-%d")
         # 队1分数
         score_home = item['score_home']
         # 队2分数
@@ -84,78 +94,52 @@ class Roll_Wangqiupipeline(object):
         odd_evens_dict_rule = item['odd_evens_dict_rule']
         sq_dict = item['sq_dict']
         new_sq_dict = json.dumps(sq_dict)
-        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+        uuid = Helper.genearte_uuid(league_name + 'hg3535')
         """联赛"""
-        last_time = '2019-12-31 23:59:59'
-        league_dict = {"game_code": "wq", "title": "league", "source": "hg3535"}
-        league_list = []
+        last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
 
-        league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
-        league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
-        league_data = dict(zip(league_key, league_value))
-        league_list.append(league_data)
-        league_dict['data'] = league_list
-        if self.db.hg3535_wq_league.find({'lg_id': league_id}).count() < 1:
-            res = Helper.async_post(url + '/setLeague', league_dict)
-            print(res)
-            self.db.hg3535_wq_league.insert(league_list)
+        if self.db.wq_league35.find({'lg_id': league_id}).count() < 1:
+            league_dict = {"game_code": "wq", "title": "league", "source": "hg3535"}
+            league_list = []
 
-        """赛事"""
-        competition = self.db.hg3535_wq_competition.find_one({"match_id": match_id})
-        match_list = []
-        if competition:
-            print('网球赛事已存在,修改网球赛事四状态')
-            is_morningplate = competition['is_morningplate']
-            is_rollball = competition['is_rollball']
-            is_stringscene = competition['is_stringscene']
-            is_today = competition['is_today']
-            status = competition['status']
-            match_date = competition['match_date']
-            match_time = competition['match_time']
-            us_time = competition['us_time']
-            if is_rollball != 1 or status != 1:
-                match_dict = {"game_code": "wq", "title": "match", "source": "hg3535"}
-                match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                             "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                             "half_match_id", "is_today", 'rule']
-                match_value = [team_home, team_guest, league_id, 1, match_id, match_date, match_time, tag_number,
-                               "hg3535", 1, is_morningplate, is_stringscene, us_time, uuid, 0, is_today, '']
-                match_data = dict(zip(match_key, match_value))
-                match_list.append(match_data)
-                match_dict['data'] = match_list
-                res = Helper.async_post(url + '/setMatch', match_dict)
-                print(res)
-                self.db.hg3535_wq_competition.insert(match_list)
-                self.db.hg3535_wq_competition.update({'match_id': str(match_id)},
-                                                     {"$set": {"is_rollball": 1, "status": 1}},
-                                                     upsert=True)
+            league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
+            league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
+            league_data = dict(zip(league_key, league_value))
+            league_list.append(league_data)
+            league_dict['data'] = league_list
+            res = Helper.async_post(LEAGUE_URL, league_dict)
+            if '成功' in res:
+                self.db.wq_league35.insert(league_data)
+                logger.info('网球联赛提交成功, {}'.format(res))
             else:
-                print("网球赛事已存在,网球赛事状态时间未改变,不做修改")
+                logger.warning('网球联赛提交失败, {}'.format(res))
+                logger.warning(league_dict)
         else:
-            is_rollball = 1
-            is_today = 0
-            is_morningplate = 0
-            is_stringscene = 0
+            logger.info('网球联赛已存在, 不提交')
+
+        """赛事"""
+        if self.db.hg3535_wq_competition35.find({"match_id": match_id, 'is_rollball': 1}).count() < 1:
+            match_list = []
             match_dict = {"game_code": "wq", "title": "match", "source": "hg3535"}
             match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
                          "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
                          "half_match_id", "is_today", 'rule']
-            match_value = [team_home, team_guest, league_id, 1, match_id, r_ctime, "00:00", tag_number,
-                           "hg3535", is_rollball, is_morningplate, is_stringscene, utime, uuid, 0, is_today, '']
+            match_value = [team_home, team_guest, league_id, 1, match_id, match_date, '00:00', tag_number,
+                           "hg3535", 1, 0, 0, utime, uuid, 0, 0, rule]
             match_data = dict(zip(match_key, match_value))
             match_list.append(match_data)
             match_dict['data'] = match_list
-            res = Helper.async_post(url + '/setMatch', match_dict)
-            print(res)
-            self.db.hg3535_wq_competition.insert(match_list)
+            res = Helper.async_post(MATCH_URL, match_dict)
+            if '成功' in res:
+                self.db.wq_competition35.insert(match_data)
+                logger.info('网球赛事提交成功, {}'.format(res))
+            else:
+                logger.warning('网球赛事提交失败, {}'.format(res))
+                logger.warning(match_data)
+        else:
+            logging.info('网球赛事已存在, 不提交')
 
         """赔率"""
-        try:
-            res = self.db.hg3535_wq_odds.find_one({'match_id': str(match_id), 'pt': pt})
-            odds_only_list = res['odds_only']
-        except:
-            res = ''
-            odds_only_list = []
         data_list = []
         odds_onlys = []
         # 滚球独赢
@@ -163,7 +147,7 @@ class Roll_Wangqiupipeline(object):
             for key, value in kemps_dict.items():
                 if value:
                     sole_str = 'C' + str(key) + '0' + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     odds_str = 'C' + str(key) + '0' + '0' + str(value) + 'hg3535' + str(match_id)
                     odds_only = Helper.genearte_MD5(odds_str, pt)
                     kemps_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
@@ -171,63 +155,57 @@ class Roll_Wangqiupipeline(object):
                     kemps_value = [match_id, league_id, key, "0", 0, 'C', value, '',
                                    odds_only, sole, "hg3535", "0", ""]
                     kemps_data = dict(zip(kemps_key, kemps_value))
-                    odds_onlys.append(odds_only)
-                    if odds_only not in odds_only_list:
-                        data_list.append(kemps_data)
+
+                    data_list.append(kemps_data)
         # 滚球让盘
         if concedes_dict:
             for key, value in concedes_dict.items():
                 if value:
                     sole_str = 'LD' + str(key) + '0' + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     odds_str = 'LD' + str(key) + '0' + str(concedes_dict_rule[key]) + str(
                         value) + 'hg3535' + str(match_id)
-                    odds_only = Helper.genearte_MD5(odds_str)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
                     condition = fuhao(concedes_dict_rule[key])
                     concedes_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                     "condition", "odds_only", "sole", "source", "type", "team"]
                     concedes_value = [match_id, league_id, key, "0", 0, 'LD', value, condition,
                                       odds_only, sole, "hg3535", "0", ""]
                     concedes_data = dict(zip(concedes_key, concedes_value))
-                    odds_onlys.append(odds_only)
-                    if odds_only not in odds_only_list:
-                        data_list.append(concedes_data)
+
+                    data_list.append(concedes_data)
         # 滚球让局
         if bureaus_dict:
             for key, value in bureaus_dict.items():
                 if value:
                     sole_str = 'LB' + str(key) + '0' + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     odds_str = 'LB' + str(key) + '0' + str(bureaus_dict_rule[key]) + str(
                         value) + 'hg3535' + str(match_id)
-                    odds_only = Helper.genearte_MD5(odds_str)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
                     condition = fuhao(bureaus_dict_rule[key])
                     bureaus_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                    "condition", "odds_only", "sole", "source", "type", "team"]
                     bureaus_value = [match_id, league_id, key, "0", 0, 'LB', value, condition,
                                      odds_only, sole, "hg3535", "0", ""]
                     bureaus_data = dict(zip(bureaus_key, bureaus_value))
-                    odds_onlys.append(odds_only)
-                    if odds_only not in odds_only_list:
-                        data_list.append(bureaus_data)
+                    data_list.append(bureaus_data)
         # 滚球总局数大小
         if total_number_dict:
             for key, value in total_number_dict.items():
                 if value:
                     sole_str = 'TN' + str(key) + '0' + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     odds_str = 'TN' + str(key) + '0' + str(
                         total_number_dict_rule[key]) + str(value) + 'hg3535' + str(match_id)
-                    odds_only = Helper.genearte_MD5(odds_str)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
                     condition = fuhao(total_number_dict_rule[key])
                     total_number_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                         "condition", "odds_only", "sole", "source", "type", "team"]
                     total_number_value = [match_id, league_id, key, "0", 0, 'TN', value,
                                           condition, odds_only, sole, "hg3535", "0", ""]
                     total_number_data = dict(zip(total_number_key, total_number_value))
-                    odds_onlys.append(odds_only)
-                    if odds_only not in odds_only_list:
-                        data_list.append(total_number_data)
+                    data_list.append(total_number_data)
         # 滚球总局数单双
         if odd_evens_dict:
             for key, value in odd_evens_dict.items():
@@ -236,42 +214,41 @@ class Roll_Wangqiupipeline(object):
                     odds_str = "TS" + str(key) + '0' + str(odd_evens_dict_rule[key]) + str(
                         value) + "hg3535" + str(match_id)
                     sole_str = "TS" + str(key) + '0' + str(match_id) + "hg3535"
-                    odds_only = Helper.genearte_MD5(odds_str)
-                    sole = Helper.genearte_MD5(sole_str)
-                    odds_onlys.append(odds_only)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     odd_evens_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                      "condition", "odds_only", "sole", "source", "type", "team"]
                     odd_evens_value = [match_id, league_id, key, "0", 0, 'TS', value,
                                        condition, odds_only, sole, "hg3535", "0", ""]
                     odd_evens_data = dict(zip(odd_evens_key, odd_evens_value))
-                    if odds_only not in odds_only_list:
-                        data_list.append(odd_evens_data)
+                    data_list.append(odd_evens_data)
         odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
                     "is_stringscene", "utime", "pt"]
         odds_value = ["wq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid,
                       0, utime, pt]
         odds_dict = dict(zip(odds_key, odds_value))
-        # print(odds_dict)
         if data_list:
-            res_data = Helper.async_post(url + '/setOdds', odds_dict)
-            print(res_data)
-            if "成功" in res_data:
-                if res:
-                    self.db.hg3535_wq_odds.update({'match_id': match_id, 'pt': pt}, {
-                        '$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
-                else:
-                    self.db.hg3535_wq_odds.insert(odds_dict)
+            res = Helper.async_post(ODDS_URL, odds_dict)
+            if "成功" in res:
+                logger.info('网球滚球赔率提交成功, {}'.format(res))
+                logger.info(odds_dict)
+            else:
+                logger.warning('网球滚球赔率提交失败, {}'.format(res))
+                logger.warning(odds_dict)
+        else:
+            logger.info('网球滚球详细赔率列表为空, 不提交')
 
         # 赛事结果
         da_list = []
         wq_rball = {"lg_id": league_id, "home_player_name": team_home, "guest_player_name": team_guest,
                     "home_player_let_plate": '', "guest_player_let_plate": '', "home_player_let_inning": "",
-                    "guest_player_let_inning": "", "all_inning": score_dict['total_inning'],
+                    # "guest_player_let_inning": "", "all_inning": score_dict['total_inning'],
+                    "guest_player_let_inning": "", "all_inning": "",
                     "home_player_score": score_home,
                     "guest_player_score": score_guest,
                     "status": 1, "first_score_player": "", "last_score_player": "",
-                    "first_inning_score": score_dict['one_score'],
-                    "second_inning_score": score_dict['second_score'], "third_inning_score": score_dict['third_score'],
+                    "first_inning_score": "",
+                    "second_inning_score": "", "third_inning_score": "",
                     "match_winer_player": "", "update_time": "",
                     "match_time": time_game, "match_process": jijie, "tag": tag_number, "match_id": match_id,
                     "source": "hg3535", "result_mark": score_dict, "warn_more": '', "uuid": uuid,
@@ -288,8 +265,15 @@ class Roll_Wangqiupipeline(object):
         }
         if da_list:
             try:
-                res = Helper.async_post(url + '/setMatchResult', r_data_dict)
-                print(res)
+                res = Helper.async_post(MATCH_RESULT, r_data_dict)
+                if "成功" in res:
+                    logger.info('网球滚球结果记录提交成功, {}'.format(res))
+                    logger.info(r_data_dict)
+                else:
+                    logger.warning('网球滚球结果记录提交失败, {}'.format(res))
+                    logger.warning(r_data_dict)
             except Exception as e:
-                logger.warning('网球滚球接口数据异常, 提交失败')
-                logger.warning(e)
+                logger.warning("网球接口数据异常, 提交失败, {}".format(e))
+        else:
+            logger.info('网球滚球结果记录为空, 不提交')
+        # reactor.callFromThread(out.callback, item)

+ 2 - 2
hg3535/pipeline/roll_zuqiu.py

@@ -321,7 +321,7 @@ class Roll_Zuqiupipeline(object):
         sole = Helper.genearte_MD5(sole_str, pt)
         capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                            "odds_only", "sole", "source", "type", "team"]
-        capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_home, '2',
+        capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_guest, '2',
                              odds_only, sole, "hg3535", "0", ""]
         capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
         data_list.append(capot_guest_data)
@@ -536,7 +536,7 @@ class Roll_Zuqiupipeline(object):
                     logger.warning(r_data_dict)
             except Exception as e:
                 logger.warning('滚球数据接口异常,提交失败, {}'.format(e))
-        reactor.callFromThread(out.callback, item)
+        # reactor.callFromThread(out.callback, item)
 
 
 

+ 81 - 140
hg3535/pipeline/wangqiu.py

@@ -15,7 +15,7 @@ class Wangqiupipeline(object):
     def open_spider(self, spider):
         # self.connection = AsyncIOMotorClient("mongodb://{}:{}@{}:{}/database?authSource={}".format('kaiyou', 'kaiyou', '192.168.2.200', 27017, 'kaiyou'))
         # session = aiohttp.ClientSession()
-        self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST)
+        self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST, authSource='kaiyou')
         self.db = self.mongo[M_DB]
 
     @defer.inlineCallbacks
@@ -26,9 +26,7 @@ class Wangqiupipeline(object):
         defer.returnValue(item)
 
     def _do_calculation(self, item, out):
-        wq_odds = []
         logger = logging.getLogger(__name__)
-        url = 'http://admin.5gogo.com'
         # logger.warning(query.addErrback(self.handle_error, item, spider))
         # 联赛id
         league_id = item['league_id']
@@ -76,7 +74,7 @@ class Wangqiupipeline(object):
         jijie = item['jijie']
         # 球队得分
         qiudui = item['qiudui']
-        pt = item['pt']
+        pt = str(item['pt'])
         # 让盘
         concedes_dict = item['concedes_dict']
         concedes_dict_rule = item['concedes_dict_rule']
@@ -95,119 +93,67 @@ class Wangqiupipeline(object):
         us_time = ctime
         match_date, match_time, time3 = new_time(ctime)
         n_time = out_time(time3, 3)
-        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+        uuid = Helper.genearte_uuid(league_name + 'hg3535')
 
         """联赛"""
-        last_time = '2019-12-31 23:59:59'
-        league_dict = {"game_code": "wq", "title": "league", "source": "hg3535"}
-        league_list = []
+        last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
 
-        league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
-        league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
-        league_data = dict(zip(league_key, league_value))
-        league_list.append(league_data)
-        league_dict['data'] = league_list
-        # print(league_list)
-        # print(league_dict)
-        if self.db.hg3535_wq_league.find({'lg_id': league_id}).count() < 1:
-            res = Helper.async_post(url + '/setLeague', league_dict)
-            print(res)
-            self.db.hg3535_wq_league.insert(league_list)
+        if self.db.wq_league35.find({'lg_id': league_id}).count() < 1:
+            league_dict = {"game_code": "wq", "title": "league", "source": "hg3535"}
+            league_list = []
+            league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
+            league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
+            league_data = dict(zip(league_key, league_value))
+            league_list.append(league_data)
+            league_dict['data'] = league_list
+            res = Helper.async_post(LEAGUE_URL, league_dict)
+            if '成功' in res:
+                self.db.wq_league35.insert(league_data)
+                logger.info('网球联赛提交成功, {}'.format(res))
+            else:
+                logger.warning('网球联赛提交失败, {}'.format(res))
+                logger.warning(league_dict)
+        else:
+            logger.info('网球联赛已存在, 不提交')
 
         """赛事"""
-        competition = self.db.wq_competition.find_one({"match_id": match_id})
-        match_list = []
-        if competition:
-            print('赛事已存在,修改赛事四状态')
-            is_morningplate = competition['is_morningplate']
-            is_rollball = competition['is_rollball']
-            is_stringscene = competition['is_stringscene']
-            is_today = competition['is_today']
-            lmtime = competition['match_time']
-            if pt == 3:
-                if is_stringscene != 1 or lmtime != match_time:
-                    match_dict = {"game_code": "wq", "title": "match", "source": "hg3535"}
-                    match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                                 "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                                 "half_match_id", "is_today", 'rule']
-                    match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
-                                   "hg3535", is_rollball, is_morningplate, 1, us_time, uuid, 0, is_today, '']
-                    match_data = dict(zip(match_key, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_wq_competition.update({'match_id': match_id},
-                                                         {"$set": {"is_stringscene": 1, 'match_time': match_time}},
-                                                         upsert=True)
-            if pt == 2:
-                if is_morningplate != 1 or lmtime != match_time:
-                    match_dict = {"game_code": "wq", "title": "match", "source": "hg3535"}
-                    match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                                 "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                                 "half_match_id", "is_today", 'rule']
-                    match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
-                                   "hg3535", is_rollball, 1, is_stringscene, us_time, uuid, 0, is_today, '']
-                    match_data = dict(zip(match_key, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_wq_competition.update({'match_id': match_id},
-                                                         {"$set": {"is_morningplate": 1, 'match_time': match_time}},
-                                                         upsert=True)
-            if pt == 1:
-                if is_today != 1 or lmtime != match_time:
-                    match_dict = {"game_code": "wq", "title": "match", "source": "hg3535"}
-                    match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                                 "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                                 "half_match_id", "is_today", 'rule']
-                    match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
-                                   "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, 1, '']
-                    match_data = dict(zip(match_kay, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_wq_competition.update({'match_id': match_id},
-                                                         {"$set": {"is_today": 1, 'match_time': match_time}},
-                                                         upsert=True)
-            else:
-                print("赛事已存在,赛事状态时间未改变,不做修改")
+        pt_dict = {'1': 'is_today', '2': 'is_morningplate', '3': 'is_stringscene', '4': 'is_rollball'}
+        pt_status = pt_dict[pt]
+        if pt == '3':
+            is_rollball = 0
+            is_today = 0
+            is_morningplate = 0
+            is_stringscene = 1
+        elif pt == '2':
+            is_rollball = 0
+            is_today = 0
+            is_morningplate = 1
+            is_stringscene = 0
         else:
-            if pt == 3:
-                is_rollball = 0
-                is_today = 0
-                is_morningplate = 0
-                is_stringscene = 1
-            elif pt == 2:
-                is_rollball = 0
-                is_today = 0
-                is_morningplate = 1
-                is_stringscene = 0
-            else:
-                is_today = 1
-                is_rollball = 0
-                is_morningplate = 0
-                is_stringscene = 0
+            is_today = 1
+            is_rollball = 0
+            is_morningplate = 0
+            is_stringscene = 0
+        if self.db.wq_competition35.find({'match_id': match_id, pt_status: 1}).count() < 1:
+            match_list = []
             match_dict = {"game_code": "wq", "title": "match", "source": "hg3535"}
-            match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time", "tag",
-                         "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
+            match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
+                         "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
                          "half_match_id", "is_today", 'rule']
-            match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number, "hg3535",
-                           is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today, '']
-            match_data = dict(zip(match_kay, match_value))
+            match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
+                           "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today, '']
+            match_data = dict(zip(match_key, match_value))
             match_list.append(match_data)
             match_dict['data'] = match_list
-            res = Helper.async_post(url + '/setMatch', match_dict)
-            print(res)
-            self.db.hg3535_wq_competition.insert(match_list)
+            res = Helper.async_post(MATCH_URL, match_dict)
+            if '成功' in res:
+                self.db.wq_competition35.insert(match_data)
+                logger.info('网球赛事提交成功, {}'.format(res))
+            else:
+                logger.warning('网球赛事提交失败, {}'.format(res))
+                logger.warning(match_data)
+        else:
+            logging.info('网球赛事已存在, 不提交')
 
         """赔率"""
         try:
@@ -223,44 +169,40 @@ class Wangqiupipeline(object):
         if concedes_dict:
             for key, value in concedes_dict.items():
                 sole_str = 'LD' + str(key) + '0' + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'LD' + str(key) + str(match_id) + 'hg3535' + str(concedes_dict_rule[key]) + str(
                     value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(concedes_dict_rule[key])
                 concedes_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                                      "odds_only", "sole", "source", "type", "team"]
                 concedes_dict_value = [match_id, league_id, key, '0', 0, 'LD', value, condition,
                                        odds_only, sole, 'hg3535', '0', '']
                 concedes_dict_data = dict(zip(concedes_dict_key, concedes_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(concedes_dict_data)
+                data_list.append(concedes_dict_data)
         # 让局
         if bureaus_dict:
             for key, value in bureaus_dict.items():
                 sole_str = 'LB' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'LB' + str(key) + str(match_id) + 'hg3535' + str(bureaus_dict_rule[key]) + str(
                     value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(bureaus_dict_rule[key])
                 bureaus_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                                     "odds_only", "sole", "source", "type", "team"]
                 bureaus_dict_value = [match_id, league_id, key, '0', 0, 'LB', value, condition,
                                       odds_only, sole, 'hg3535', '0', '']
                 bureaus_dict_data = dict(zip(bureaus_dict_key, bureaus_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(bureaus_dict_data)
+                data_list.append(bureaus_dict_data)
         # 总局数大小
         if total_number_dict:
             for key, value in total_number_dict.items():
                 sole_str = 'TN' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'TN' + str(key) + str(match_id) + 'hg3535' + str(
                     total_number_dict_rule[key]) + str(value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(total_number_dict_rule[key])
                 total_number_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                          "condition",
@@ -268,42 +210,36 @@ class Wangqiupipeline(object):
                 total_number_dict_value = [match_id, league_id, key, '0', 0, 'TN', value, condition,
                                            odds_only, sole, 'hg3535', '0', '']
                 total_number_dict_data = dict(zip(total_number_dict_key, total_number_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(total_number_dict_data)
+                data_list.append(total_number_dict_data)
         # 总局数单双
         if odd_evens_dict:
             for key, value in odd_evens_dict.items():
                 sole_str = 'TS' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'TS' + str(key) + str(match_id) + 'hg3535' + str(odd_evens_dict_rule[key]) + str(
                     value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(odd_evens_dict_rule[key])
                 odd_evens_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                                       "odds_only", "sole", "source", "type", "team"]
                 odd_evens_dict_value = [match_id, league_id, key, '0', 0, 'TS', value, condition,
                                         odds_only, sole, 'hg3535', '0', '']
                 odd_evens_dict_data = dict(zip(odd_evens_dict_key, odd_evens_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(odd_evens_dict_data)
+                data_list.append(odd_evens_dict_data)
         # 冠军
         if kemps_dict:
             for key, value in kemps_dict.items():
                 sole_str = 'C' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'C' + str(key) + str(match_id) + 'hg3535' + '2' + str(value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 kemps_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                                   "odds_only", "sole", "source", "type", "team"]
                 kemps_dict_value = [match_id, league_id, key, '0', 0, 'C', value, '',
                                     odds_only, sole, 'hg3535', '0', '']
                 kemps_dict_data = dict(zip(kemps_dict_key, kemps_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(kemps_dict_data)
-        if pt == 3:
+                data_list.append(kemps_dict_data)
+        if pt == '3':
             ris_stringscene = 1
         else:
             ris_stringscene = 0
@@ -315,11 +251,16 @@ class Wangqiupipeline(object):
         # print(odds_dict)
         # print(123)
         if data_list:
-            res = Helper.async_post(url + '/setOdds', odds_dict)
-            print(res)
-            if '成功' in res:
-                if result:
-                    self.db.hg3535_wq_odds.update({'match_id': match_id, 'pt': pt}, {
-                        '$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
+            res = Helper.async_post(ODDS_URL, odds_dict)
+            if res:
+                if "成功" in res:
+                    logger.info('网球赔率提交成功, {}'.format(res))
+                    logger.info(odds_dict)
                 else:
-                    self.db.hg3535_wq_odds.insert(odds_dict)
+                    logger.warning('网球赔率提交失败, {}'.format(res))
+                    logger.warning(odds_dict)
+            else:
+                logger.warning('网球详细接口赔率返回异常, {}'.format(res))
+                logger.warning(odds_dict)
+        else:
+            logger.info('网球详细赔率列表为空, 不提交')

+ 69 - 64
hg3535/pipeline/zuqiu.py

@@ -15,17 +15,18 @@ class Zuqiupipeline(object):
     def open_spider(self, spider):
         # self.connection = AsyncIOMotorClient("mongodb://{}:{}@{}:{}/database?authSource={}".format('kaiyou', 'kaiyou', '192.168.2.200', 27017, 'kaiyou'))
         # session = aiohttp.ClientSession()
-        self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST)
+        self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST, authSource='kaiyou')
         self.db = self.mongo[M_DB]
 
-    @defer.inlineCallbacks
-    def process_item(self, item, spider):
-        out = defer.Deferred()
-        reactor.callInThread(self._do_calculation, item, out)
-        yield out
-        defer.returnValue(item)
+    # @defer.inlineCallbacks
+    # def process_item(self, item, spider):
+    #     out = defer.Deferred()
+    #     reactor.callInThread(self._do_calculation, item, out)
+    #     yield out
+    #     defer.returnValue(item)
 
-    def _do_calculation(self, item, out):
+    def process_item(self, item, spider):
+    # def _do_calculation(self, item, out):
         logger = logging.getLogger(__name__)
         # 比赛日期
         try:
@@ -44,7 +45,7 @@ class Zuqiupipeline(object):
         # 比赛时间
         time_game = str(item['time_game'])
         # 比赛时间,时间戳
-        us_time = str(res.year) + "-" + month + "-" + day + " " + time_game + ":00"
+        us_time = str(datetime.datetime.now().year) + "-" + month + "-" + day + " " + time_game + ":00"
         # 现在时间,时间戳
         utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
         # 比赛id
@@ -119,7 +120,7 @@ class Zuqiupipeline(object):
         half_size_guest_rule = item["half_size_guest_rule"]
         half_size_home = item["half_size_home"]
         half_size_home_rule = item["half_size_home_rule"]
-        # zuqiu = item['zuqiu']
+        # # zuqiu = item['zuqiu']
         data_list = []
         odds_onlys = []
         # half_size_guest
@@ -191,67 +192,71 @@ class Zuqiupipeline(object):
         half_concede_guest_rule = item["half_concede_guest_rule"]
         half_concede_guest = item["half_concede_guest"]
         # half_concede_home
-        for index, value in enumerate(half_concede_guest):
-            hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
-                value) + "hg3535" + str(match_id)
-            sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str, pt)
-            sole = Helper.genearte_MD5(sole_str, pt)
-            half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
-                                      "odds_only", "sole", "source", "type", "team"]
-            condition = fuhao(half_concede_guest_rule[index])
-            half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
-                                        odds_only, sole, "hg3535", "0", ""]
-            half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
-            data_list.append(half_concede_guest_data)
+        if half_concede_guest:
+            for index, value in enumerate(half_concede_guest):
+                hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
+                    value) + "hg3535" + str(match_id)
+                sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
+                half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                          "odds_only", "sole", "source", "type", "team"]
+                condition = fuhao(half_concede_guest_rule[index])
+                half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
+                                            odds_only, sole, "hg3535", "0", ""]
+                half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
+                data_list.append(half_concede_guest_data)
 
         # half_concede_home
-        for index, value in enumerate(half_concede_home):
-            hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
-                value) + "hg3535" + str(match_id)
-            sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str, pt)
-            sole = Helper.genearte_MD5(sole_str, pt)
-            half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
-                                     "odds_only", "sole", "source", "type", "team"]
-            condition = fuhao(half_concede_home_rule[index])
-            half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
-                                       odds_only, sole, "hg3535", "0", ""]
-            half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
-            data_list.append(half_concede_home_data)
+        if half_concede_home:
+            for index, value in enumerate(half_concede_home):
+                hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
+                    value) + "hg3535" + str(match_id)
+                sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
+                half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                         "odds_only", "sole", "source", "type", "team"]
+                condition = half_concede_home_rule[index]
+                half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
+                                           odds_only, sole, "hg3535", "0", ""]
+                half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
+                data_list.append(half_concede_home_data)
 
         concede_guest = item["concede_guest"]
         concede_guest_rule = item["concede_guest_rule"]
         concede_home = item["concede_home"]
         concede_home_rule = item["concede_home_rule"]
         # concede_guest
-        for index, value in enumerate(concede_guest):
-            hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
-                value) + "hg3535" + str(match_id)
-            sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str, pt)
-            sole = Helper.genearte_MD5(sole_str, pt)
-            concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
-                                 "odds_only", "sole", "source", "type", "team"]
-            condition = fuhao(concede_guest_rule[index])
-            concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
-                                   odds_only, sole, "hg3535", "0", ""]
-            concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
-            data_list.append(concede_guest_data)
+        if concede_guest:
+            for index, value in enumerate(concede_guest):
+                hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
+                    value) + "hg3535" + str(match_id)
+                sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
+                concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                     "odds_only", "sole", "source", "type", "team"]
+                condition = concede_guest_rule[index]
+                concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
+                                       odds_only, sole, "hg3535", "0", ""]
+                concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
+                data_list.append(concede_guest_data)
         # concede_home
-        for index, value in enumerate(concede_home):
-            hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
-                value) + "hg3535" + str(match_id)
-            sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str, pt)
-            sole = Helper.genearte_MD5(sole_str, pt)
-            concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
-                                "odds_only", "sole", "source", "type", "team"]
-            condition = fuhao(concede_home_rule[index])
-            concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
-                                  sole, "hg3535", "0", ""]
-            concede_guest_data = dict(zip(concede_home_key, concede_home_value))
-            data_list.append(concede_guest_data)
+        if concede_home:
+            for index, value in enumerate(concede_home):
+                hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
+                    value) + "hg3535" + str(match_id)
+                sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
+                concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                    "odds_only", "sole", "source", "type", "team"]
+                condition = concede_home_rule[index]
+                concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
+                                      sole, "hg3535", "0", ""]
+                concede_guest_data = dict(zip(concede_home_key, concede_home_value))
+                data_list.append(concede_guest_data)
 
         # 独赢----------------------------------------------------------------------------------------------------------
         p_code = 'C'
@@ -329,7 +334,7 @@ class Zuqiupipeline(object):
         sole = Helper.genearte_MD5(sole_str, pt)
         capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                            "odds_only", "sole", "source", "type", "team"]
-        capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_home, '2',
+        capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_guest, '2',
                              odds_only, sole, "hg3535", "0", ""]
         capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
         data_list.append(capot_guest_data)
@@ -517,4 +522,4 @@ class Zuqiupipeline(object):
             else:
                 logger.warning('足球相信赔率提交失败, {}'.format(response_data))
                 logger.warning(odds_dict)
-        reactor.callFromThread(out.callback, item)
+        # reactor.callFromThread(out.callback, item)

+ 4 - 4
hg3535/settings.py

@@ -137,13 +137,13 @@ CONCURRENT_ITEMS = 1000
 # LOG_FILE = './log/'
 
 
-# M_HOST = '192.168.2.200'
-M_HOST = '127.0.0.1'
+M_HOST = '192.168.2.200'
+# M_HOST = '127.0.0.1'
 M_POST = 27017
 M_USER = 'kaiyou'
 M_DB = 'kaiyou'
-# M_PASSWORD = 'kaiyou'
-M_PASSWORD = '123456'
+M_PASSWORD = 'kaiyou'
+# M_PASSWORD = '123456'
 
 LEAGUE_URL = 'http://stadmin.bocai108.com:19093/setLeague'
 MATCH_URL = 'http://stadmin.bocai108.com:19093/setMatch'

+ 606 - 577
hg3535/spiders/roll_lanqiu.py

@@ -75,611 +75,640 @@ class LanqiuSpider(scrapy.Spider):
             # 联赛名
             league_name = new_datas.get("c", "").get("n", "")
             new_data = new_datas.get("es", "")
-            result = new_data[0]
-            # 比赛id
-            game_id = str(result['k'])
-            # 球队1
-            team_home = result['i'][0]
-            # 球队2
-            team_guest = result['i'][1]
-            # 数量(97>)
-            number = result['i'][2]
-            # 比赛状态
-            zhuangtai = result['i'][3]
-            # 日期
-            data_game = result['i'][4]
-            # 开赛时间  滚球实际只有一个进行时间
-            # time_game = result['i'][5]
-            time_game = result['sb']['ct']
-            # 队1分数
-            score_home1 = result['i'][10]
-            # 队2分数
-            score_guest1 = result['i'][11]
-            # 第几节
-            jijie = result['i'][12]
-            # 球队得分
-            qiudui = result['pci'].get('ctn', "")
-            # ----------------------------------------让球分割线---------------------------------------------------------------------------
-            concedes_dict = {}
-            concedes_dict_rule = {}
-            try:
-                concedes = result['o']["ah"]["v"]
-                # print(concedes)
-                # 主队让球条件,主队让球赔率,客队让球条件,客队让球赔率
-                concede_home_rule, concede_home, concede_guest_rule, concede_guest = rangqiu_daxiao(inner=concedes)
-                concedes_dict_rule['coh'] = concede_home_rule
-                concedes_dict['coh'] = concede_home
-                concedes_dict_rule['cog'] = concede_guest_rule
-                concedes_dict['cog'] = concede_guest
-            except:
-                concedes_dict_rule['coh'] = ""
-                concedes_dict['coh'] = ""
-                concedes_dict_rule['cog'] = ""
-                concedes_dict['cog'] = ""
-            # print(concedes_dict)
-            try:
-                half_concedes = result['o']["ah1st"]["v"]
-                # 上半场 主队让球条件
-                half_concede_home_rule, half_concede_home, half_concede_guest_rule, half_concede_guest = rangqiu_daxiao(inner=half_concedes)
-                concedes_dict_rule['coh_h'] = half_concede_home_rule
-                concedes_dict['coh_h'] = half_concede_home
-                concedes_dict_rule['cog_h'] = half_concede_guest_rule
-                concedes_dict['cog_h'] = half_concede_guest
-
-            except:
-                concedes_dict_rule['coh_h'] = ""
-                concedes_dict['coh_h'] = ""
-                concedes_dict_rule['cog_h'] = ""
-                concedes_dict['cog_h'] = ""
-
-            # 第一节让球
-            try:
-                one_concedes = result['o']["ahq1"]["v"]
-                one_concede_home_rule, one_concede_home, one_concede_guest_rule, one_concede_guest = rangqiu_daxiao(inner=one_concedes)
-                concedes_dict_rule['coh_1'] = one_concede_home_rule
-                concedes_dict['coh_1'] = one_concede_home
-                concedes_dict_rule['cog_1'] = one_concede_guest_rule
-                concedes_dict['cog_1'] = one_concede_guest
-
-            except:
-                concedes_dict_rule['coh_1'] = ""
-                concedes_dict['coh_1'] = ""
-                concedes_dict_rule['cog_1'] = ""
-                concedes_dict['cog_1'] = ""
-            # 第二节让球
-            try:
-                two_concedes = result['o']["ahq2"]["v"]
-                two_concede_home_rule, two_concede_home, two_concede_guest_rule, two_concede_guest = rangqiu_daxiao(inner=two_concedes)
-                concedes_dict_rule['coh_2'] = two_concede_home_rule
-                concedes_dict['coh_2'] = two_concede_home
-                concedes_dict_rule['cog_2'] = two_concede_guest_rule
-                concedes_dict['cog_2'] = two_concede_guest
-            except:
-                concedes_dict_rule['coh_2'] = ""
-                concedes_dict['coh_2'] = ""
-                concedes_dict_rule['cog_2'] = ""
-                concedes_dict['cog_2'] = ""
-            # 第三节让球
-            try:
-                three_concedes = result['o']["ahq3"]["v"]
-                three_concede_home_rule, three_concede_home, three_concede_guest_rule, three_concede_guest = rangqiu_daxiao(inner=three_concedes)
-                concedes_dict_rule['coh_3'] = three_concede_home_rule
-                concedes_dict['coh_3'] = three_concede_home
-                concedes_dict_rule['cog_3'] = three_concede_guest_rule
-                concedes_dict['cog_3'] = three_concede_guest
-
-            except:
-                concedes_dict_rule['coh_3'] = ""
-                concedes_dict['coh_3'] = ""
-                concedes_dict_rule['cog_3'] = ""
-                concedes_dict['cog_3'] = ""
-            # 第四节让球
-            try:
-                four_concedes = result['o']["ahq4"]["v"]
-                four_concede_home_rule, four_concede_home, four_concede_guest_rule, four_concede_guest = rangqiu_daxiao(inner=four_concedes)
-                concedes_dict_rule['coh_4'] = four_concede_home_rule
-                concedes_dict['coh_4'] = four_concede_home
-                concedes_dict_rule['cog_4'] = four_concede_guest_rule
-                concedes_dict['cog_4'] = four_concede_guest
-
-            except:
-                concedes_dict_rule['coh_4'] = ""
-                concedes_dict['coh_4'] = ""
-                concedes_dict_rule['cog_4'] = ""
-                concedes_dict['cog_4'] = ""
-            # ----------------------------------------总分大小分割线 - ---------------------------------------------------------------
-            # 全场总分大小
-            total_sizes_dict = {}
-            total_sizes_dict_rule = {}
-            try:
-                total_sizes = result['o']["ou"]["v"]
-                total_sizes_big_rule, total_sizes_big, total_sizes_small_rule, total_sizes_small = rangqiu_daxiao(inner=total_sizes)
-                total_sizes_dict_rule["tnb"] = total_sizes_big_rule
-                total_sizes_dict["tnb"] = total_sizes_big
-                total_sizes_dict_rule["tns"] = total_sizes_small_rule
-                total_sizes_dict["tns"] = total_sizes_small
-            except:
-                total_sizes_dict_rule["tnb"] = ""
-                total_sizes_dict["tnb"] = ""
-                total_sizes_dict_rule["tns"] = ""
-                total_sizes_dict["tns"] = ""
-            # 上半场总分大小
-            try:
-                half_total_sizes = result['o']["ou1st"]["v"]
-                half_total_sizes_big_rule, half_total_sizes_big, half_total_sizes_small_rule, half_total_sizes_small = rangqiu_daxiao(
-                    inner=half_total_sizes)
-                total_sizes_dict_rule["tnb_h"] = half_total_sizes_big_rule
-                total_sizes_dict["tnb_h"] = half_total_sizes_big
-                total_sizes_dict_rule["tns_h"] = half_total_sizes_small_rule
-                total_sizes_dict["tns_h"] = half_total_sizes_small
-            except:
-                total_sizes_dict_rule["tnb_h"] = ""
-                total_sizes_dict["tnb_h"] = ""
-                total_sizes_dict_rule["tns_h"] = ""
-                total_sizes_dict["tns_h"] = ""
-            # 第一节总分大小
-            try:
-                one_total_sizes = result['o']["ou1st"]["v"]
-                one_total_sizes_big_rule, one_total_sizes_big, one_total_sizes_small_rule, one_total_sizes_small = rangqiu_daxiao(
-                    inner=one_total_sizes)
-                total_sizes_dict_rule["tnb_1"] = one_total_sizes_big_rule
-                total_sizes_dict["tnb_1"] = one_total_sizes_big
-                total_sizes_dict_rule["tns_1"] = one_total_sizes_small_rule
-                total_sizes_dict["tns_1"] = one_total_sizes_small
-            except:
-                total_sizes_dict_rule["tnb_1"] = ""
-                total_sizes_dict["tnb_1"] = ""
-                total_sizes_dict_rule["tns_1"] = ""
-                total_sizes_dict["tns_1"] = ""
-            # 第二节场总分大小
-            try:
-                two_total_sizes = result['o']["ou2st"]["v"]
-                two_total_sizes_big_rule, two_total_sizes_big, two_total_sizes_small_rule, two_total_sizes_small = rangqiu_daxiao(
-                    inner=two_total_sizes)
-                total_sizes_dict_rule["tnb_2"] = two_total_sizes_big_rule
-                total_sizes_dict["tnb_2"] = two_total_sizes_big
-                total_sizes_dict_rule["tns_2"] = two_total_sizes_small_rule
-                total_sizes_dict["tns_2"] = two_total_sizes_small
-            except:
-                total_sizes_dict_rule["tnb_2"] = ""
-                total_sizes_dict["tnb_2"] = ""
-                total_sizes_dict_rule["tns_2"] = ""
-                total_sizes_dict["tns_2"] = ""
-            # 第三节总分大小
-            try:
-                three_total_sizes = result['o']["ou3st"]["v"]
-                three_total_sizes_big_rule, three_total_sizes_big, three_total_sizes_small_rule, three_total_sizes_small = rangqiu_daxiao(
-                    inner=three_total_sizes)
-                total_sizes_dict_rule["tnb_3"] = three_total_sizes_big_rule
-                total_sizes_dict["tnb_3"] = three_total_sizes_big
-                total_sizes_dict_rule["tns_3"] = three_total_sizes_small_rule
-                total_sizes_dict["tns_3"] = three_total_sizes_small
-            except:
-                total_sizes_dict_rule["tnb_3"] = ""
-                total_sizes_dict["tnb_3"] = ""
-                total_sizes_dict_rule["tns_3"] = ""
-                total_sizes_dict["tns_3"] = ""
-            # 第四节总分大小
-            try:
-                four_total_sizes = result['o']["ou4st"]["v"]
-                four_total_sizes_big_rule, four_total_sizes_big, four_total_sizes_small_rule, four_total_sizes_small = rangqiu_daxiao(
-                    inner=four_total_sizes)
-                total_sizes_dict_rule["tnb_4"] = four_total_sizes_big_rule
-                total_sizes_dict["tnb_4"] = four_total_sizes_big
-                total_sizes_dict_rule["tns_4"] = four_total_sizes_small_rule
-                total_sizes_dict["tns_4"] = four_total_sizes_small
-            except:
-                total_sizes_dict_rule["tnb_4"] = ""
-                total_sizes_dict["tnb_4"] = ""
-                total_sizes_dict_rule["tns_4"] = ""
-                total_sizes_dict["tns_4"] = ""
-
-            # ----------------------------------------总分单双分割线------------------------------------------------------------------
-            # 全场 总分单双
-            odd_evens_dict = {}
-            odd_evens_dict_rule = {}
-            try:
-                odd_evens = result['o']["oe"]["v"]
-                # 全场 总分单, 全场 总分双
-                odd_evens_dict["tss"] = odd_evens[1]
-                odd_evens_dict_rule['tss'] = '单'
-                odd_evens_dict["tsd"] = odd_evens[3]
-                odd_evens_dict_rule['tsd'] = '双'
-            except:
-                odd_evens_dict["tss"] = ""
-                odd_evens_dict_rule['tss'] = '单'
-                odd_evens_dict["tsd"] = ""
-                odd_evens_dict_rule['tsd'] = '双'
-            # 上半场全场 总分单双
-
-            try:
-                half_odd_evens = result['o']["oe1st"]["v"]
-                # 上半场 总分单, 上半场 总分双
-                odd_evens_dict["tss_h"] = half_odd_evens[1]
-                odd_evens_dict_rule['tss_h'] = '单'
-                odd_evens_dict["tsd_h"] = half_odd_evens[3]
-                odd_evens_dict_rule['tsd_h'] = '双'
-            except:
-                # half_odd_even_odd = ""
-                # half_odd_even_even = ""
-                odd_evens_dict["tss_h"] = ""
-                odd_evens_dict_rule['tss_h'] = '单'
-                odd_evens_dict["tsd_h"] = ""
-                odd_evens_dict_rule['tsd_h'] = '双'
-
-            # 总分:单/双-第一节
-            try:
-                one_odd_evens = result['o']["oeq1"]["v"]
-                odd_evens_dict["tss_1"] = one_odd_evens[1]
-                odd_evens_dict_rule['tss_1'] = '单'
-                odd_evens_dict["tsd_1"] = one_odd_evens[3]
-                odd_evens_dict_rule['tsd_1'] = '双'
-            except:
-                odd_evens_dict["tss_1"] = ""
-                odd_evens_dict_rule['tss_1'] = '单'
-                odd_evens_dict["tsd_1"] = ""
-                odd_evens_dict_rule['tsd_1'] = '双'
-
-            # 总分:单/双-第二节
-            try:
-                two_odd_evens = result['o']["oeq2"]["v"]
-                odd_evens_dict["tss_2"] = two_odd_evens[1]
-                odd_evens_dict_rule['tss_2'] = '单'
-                odd_evens_dict["tsd_2"] = two_odd_evens[3]
-                odd_evens_dict_rule['tsd_2'] = '双'
-            except:
-                # two_odd_even_odd = ""
-                # two_odd_even_even = ""
-                odd_evens_dict["tss_2"] = ""
-                odd_evens_dict_rule['tss_2'] = '单'
-                odd_evens_dict["tsd_2"] = ""
-                odd_evens_dict_rule['tsd_2'] = '双'
-
-            # 总分:单/双-第三节
-            try:
-                three_odd_evens = result['o']["oeq3"]["v"]
-                odd_evens_dict["tss_3"] = three_odd_evens[1]
-                odd_evens_dict_rule['tss_3'] = '单'
-                odd_evens_dict["tsd_3"] = three_odd_evens[3]
-                odd_evens_dict_rule['tsd_3'] = '双'
-            except:
-                odd_evens_dict["tss_3"] = ""
-                odd_evens_dict_rule['tss_3'] = '单'
-                odd_evens_dict["tsd_3"] = ""
-                odd_evens_dict_rule['tsd_3'] = '双'
-
-            # 总分:单/双-第四节
-            try:
-                four_odd_evens = result['o']["oeq4"]["v"]
-                odd_evens_dict["tss_4"] = four_odd_evens[1]
-                odd_evens_dict_rule['tss_4'] = '单'
-                odd_evens_dict["tsd_4"] = four_odd_evens[3]
-                odd_evens_dict_rule['tsd_4'] = '双'
-            except:
-                odd_evens_dict["tss_4"] = ""
-                odd_evens_dict_rule['tss_4'] = '单'
-                odd_evens_dict["tsd_4"] = ""
-                odd_evens_dict_rule['tsd_4'] = '双'
-
-            # ----------------------------------------球队得分最后一位数分割线---------------------------------------------------------
-            # 球队得分最后一位数 主队
-            last_numbers_dict = {}
-            try:
-                last_numbers = result["p-o"][0]['o']
-                last_home = {}
-                for last_number in last_numbers:
-                    last_home[last_number[0]] = last_number[2]
-            except:
-                last_home = {}
-            last_numbers_dict["last_home"] = last_home
-            # 球队得分最后一位数 客队
-            try:
-                new_last_numbers = result["p-o"][1]['o']
-                last_guest = {}
-                for new_last_number in new_last_numbers:
-                    last_guest[new_last_number[0]] = new_last_number[2]
-            except:
-                last_guest = {}
-            last_numbers_dict["last_guest"] = last_guest
-            # ------------------------------------------------------独赢分割线---------------------------------------------------------
-            capots_dict = {}
-            # 独赢
-            try:
-                capots = result['o']["ml"]["v"]
-                capot_list = [capots[i] for i in range(len(capots)) if i % 2 == 1]
-                capot_home = capot_list[0]
-                capot_guest = capot_list[1]
-                capots_dict["ch"] = capot_home
-                capots_dict["cg"] = capot_guest
-            except:
-                capots_dict["ch"] = ""
-                capots_dict["cg"] = ""
-
-            # 上半场独赢
-            try:
-                half_capots = result['o']["ml1st"]["v"]
-                half_capot_list = [half_capots[i] for i in range(len(half_capots)) if i % 2 == 1]
-                half_capot_home = half_capot_list[0]
-                half_capot_guest = half_capot_list[1]
-                capots_dict["ch_h"] = half_capot_home
-                capots_dict["cg_h"] = half_capot_guest
-            except:
-                capots_dict["ch_h"] = ""
-                capots_dict["cg_h"] = ""
-
-            # 第一节独赢
-            try:
-                one_capots = result['o']["mlq1"]["v"]
-                one_capot_list = [one_capots[i] for i in range(len(one_capots)) if i % 2 == 1]
-                one_capot_home = one_capot_list[0]
-                one_capot_guest = one_capot_list[1]
-                capots_dict["ch_1"] = one_capot_home
-                capots_dict["cg_1"] = one_capot_guest
-            except:
-                capots_dict["ch_1"] = ""
-                capots_dict["cg_1"] = ""
-
-            # 第二节独赢
-            try:
-                two_capots = result['o']["mlq2"]["v"]
-                two_capot_list = [two_capots[i] for i in range(len(two_capots)) if i % 2 == 1]
-                two_capot_home = two_capot_list[0]
-                two_capot_guest = two_capot_list[1]
-                capots_dict["ch_2"] = two_capot_home
-                capots_dict["cg_2"] = two_capot_guest
-            except:
-                capots_dict["ch_2"] = ""
-                capots_dict["cg_2"] = ""
-
-            # 第三节独赢
-            try:
-                three_capots = result['o']["mlq3"]["v"]
-                three_capot_list = [three_capots[i] for i in range(len(three_capots)) if i % 2 == 1]
-                three_capot_home = three_capot_list[0]
-                three_capot_guest = three_capot_list[1]
-                capots_dict["ch_3"] = three_capot_home
-                capots_dict["cg_3"] = three_capot_guest
-            except:
-                capots_dict["ch_3"] = ""
-                capots_dict["cg_3"] = ""
-
-            # 第四节独赢
-            try:
-                four_capots = result['o']["mlq2"]["v"]
-                four_capot_list = [four_capots[i] for i in range(len(four_capots)) if i % 2 == 1]
-                four_capot_home = four_capot_list[0]
-                four_capot_guest = four_capot_list[1]
-                capots_dict["ch_4"] = four_capot_home
-                capots_dict["cg_4"] = four_capot_guest
-            except:
-                capots_dict["ch_4"] = ""
-                capots_dict["cg_4"] = ""
-
-            # ---------------------------------------------------华丽分割线列表es[1]--------------------------------------------------
-            # 球队得分大/小 全场主队 home
-            team_scores_dict = {}
-            team_scores_dict_rule = {}
-            try:
-                score_home = new_data[1]
-            except:
-                score_home = ""
-            if score_home:
+            # result = new_data[0]
+            for result in new_data:
+                # 比赛id
+                game_id = str(result['k'])
+                # 球队1
+                team_home = result['i'][0]
+                # 球队2
+                team_guest = result['i'][1]
+                # 数量(97>)
+                number = result['i'][2]
+                # 比赛状态
+                zhuangtai = result['i'][3]
+                # 日期
+                data_game = result['i'][4]
+                # 开赛时间  滚球实际只有一个进行时间
+                # time_game = result['i'][5]
+                time_game = result['sb']['ct']
+                # 队1分数
+                score_home1 = result['i'][10]
+                # 队2分数
+                score_guest1 = result['i'][11]
+                # 第几节
+                jijie = result['i'][12]
+                # 球队得分
+                qiudui = result['pci'].get('ctn', "")
+                # ----------------------------------------让球分割线---------------------------------------------------------------------------
+                concedes_dict = {}
+                concedes_dict_rule = {}
                 try:
-                    score_homes = score_home["o"]["ou"]['v']
-                    score_home_big_rule, score_home_big, score_home_small_rule, score_home_small = rangqiu_daxiao(inner=score_homes)
-                    team_scores_dict_rule["tbhb"] = score_home_big_rule
-                    team_scores_dict["tbhb"] = score_home_big
-                    team_scores_dict_rule["tbhs"] = score_home_small_rule
-                    team_scores_dict["tbhs"] = score_home_small
+                    concedes = result['o']["ah"]["v"]
+                    # print(concedes)
+                    # 主队让球条件,主队让球赔率,客队让球条件,客队让球赔率
+                    concede_home_rule, concede_home, concede_guest_rule, concede_guest = rangqiu_daxiao(inner=concedes)
+                    concedes_dict_rule['coh'] = concede_home_rule
+                    concedes_dict['coh'] = concede_home
+                    concedes_dict_rule['cog'] = concede_guest_rule
+                    concedes_dict['cog'] = concede_guest
                 except:
-                    team_scores_dict_rule["tbhb"] = ""
-                    team_scores_dict["tbhb"] = ""
-                    team_scores_dict_rule["tbhs"] = ""
-                    team_scores_dict["tbhs"] = ""
-                # 球队得分 上半场主队 home
+                    concedes_dict_rule['coh'] = ""
+                    concedes_dict['coh'] = ""
+                    concedes_dict_rule['cog'] = ""
+                    concedes_dict['cog'] = ""
+                # print(concedes_dict)
                 try:
-                    half_score_homes = score_home['o']['ou1st']['v']
-                    # 球队得分 上半场主队 大条件
-                    half_score_home_big_rule, half_score_home_big, half_score_home_small_rule, half_score_home_small = rangqiu_daxiao(
-                        inner=half_score_homes)
-                    team_scores_dict_rule["tbhb_h"] = half_score_home_big_rule
-                    team_scores_dict["tbhb_h"] = half_score_home_big
-                    team_scores_dict_rule["tbhs_h"] = half_score_home_small_rule
-                    team_scores_dict["tbhs_h"] = half_score_home_small
+                    half_concedes = result['o']["ah1st"]["v"]
+                    # 上半场 主队让球条件
+                    half_concede_home_rule, half_concede_home, half_concede_guest_rule, half_concede_guest = rangqiu_daxiao(inner=half_concedes)
+                    concedes_dict_rule['coh_h'] = half_concede_home_rule
+                    concedes_dict['coh_h'] = half_concede_home
+                    concedes_dict_rule['cog_h'] = half_concede_guest_rule
+                    concedes_dict['cog_h'] = half_concede_guest
+
                 except:
-                    team_scores_dict_rule["tbhb_h"] = ""
-                    team_scores_dict["tbhb_h"] = ""
-                    team_scores_dict_rule["tbhs_h"] = ""
-                    team_scores_dict["tbhs_h"] = ""
+                    concedes_dict_rule['coh_h'] = ""
+                    concedes_dict['coh_h'] = ""
+                    concedes_dict_rule['cog_h'] = ""
+                    concedes_dict['cog_h'] = ""
+
+                # 第一节让球
+                try:
+                    one_concedes = result['o']["ahq1"]["v"]
+                    one_concede_home_rule, one_concede_home, one_concede_guest_rule, one_concede_guest = rangqiu_daxiao(inner=one_concedes)
+                    concedes_dict_rule['coh_1'] = one_concede_home_rule
+                    concedes_dict['coh_1'] = one_concede_home
+                    concedes_dict_rule['cog_1'] = one_concede_guest_rule
+                    concedes_dict['cog_1'] = one_concede_guest
 
-                # 球队得分:主队-大 / 小-第一节
+                except:
+                    concedes_dict_rule['coh_1'] = ""
+                    concedes_dict['coh_1'] = ""
+                    concedes_dict_rule['cog_1'] = ""
+                    concedes_dict['cog_1'] = ""
+                # 第二节让球
                 try:
-                    one_score_homes = score_home['o']["ouq1"]["v"]
-                    one_score_home_big_rule, one_score_home_big, one_score_home_small_rule, one_score_home_small = rangqiu_daxiao(
-                        inner=one_score_homes)
-                    team_scores_dict_rule["tbhb_1"] = one_score_home_big_rule
-                    team_scores_dict["tbhb_1"] = one_score_home_big
-                    team_scores_dict_rule["tbhs_1"] = one_score_home_small_rule
-                    team_scores_dict["tbhs_1"] = one_score_home_small
+                    two_concedes = result['o']["ahq2"]["v"]
+                    two_concede_home_rule, two_concede_home, two_concede_guest_rule, two_concede_guest = rangqiu_daxiao(inner=two_concedes)
+                    concedes_dict_rule['coh_2'] = two_concede_home_rule
+                    concedes_dict['coh_2'] = two_concede_home
+                    concedes_dict_rule['cog_2'] = two_concede_guest_rule
+                    concedes_dict['cog_2'] = two_concede_guest
                 except:
-                    team_scores_dict_rule["tbhb_1"] = ""
-                    team_scores_dict["tbhb_1"] = ""
-                    team_scores_dict_rule["tbhs_1"] = ""
-                    team_scores_dict["tbhs_1"] = ""
+                    concedes_dict_rule['coh_2'] = ""
+                    concedes_dict['coh_2'] = ""
+                    concedes_dict_rule['cog_2'] = ""
+                    concedes_dict['cog_2'] = ""
+                # 第三节让球
+                try:
+                    three_concedes = result['o']["ahq3"]["v"]
+                    three_concede_home_rule, three_concede_home, three_concede_guest_rule, three_concede_guest = rangqiu_daxiao(inner=three_concedes)
+                    concedes_dict_rule['coh_3'] = three_concede_home_rule
+                    concedes_dict['coh_3'] = three_concede_home
+                    concedes_dict_rule['cog_3'] = three_concede_guest_rule
+                    concedes_dict['cog_3'] = three_concede_guest
 
-                # 球队得分:主队-大 / 小-第二节
+                except:
+                    concedes_dict_rule['coh_3'] = ""
+                    concedes_dict['coh_3'] = ""
+                    concedes_dict_rule['cog_3'] = ""
+                    concedes_dict['cog_3'] = ""
+                # 第四节让球
+                try:
+                    four_concedes = result['o']["ahq4"]["v"]
+                    four_concede_home_rule, four_concede_home, four_concede_guest_rule, four_concede_guest = rangqiu_daxiao(inner=four_concedes)
+                    concedes_dict_rule['coh_4'] = four_concede_home_rule
+                    concedes_dict['coh_4'] = four_concede_home
+                    concedes_dict_rule['cog_4'] = four_concede_guest_rule
+                    concedes_dict['cog_4'] = four_concede_guest
+
+                except:
+                    concedes_dict_rule['coh_4'] = ""
+                    concedes_dict['coh_4'] = ""
+                    concedes_dict_rule['cog_4'] = ""
+                    concedes_dict['cog_4'] = ""
+                # ----------------------------------------总分大小分割线 - ---------------------------------------------------------------
+                # 全场总分大小
+                total_sizes_dict = {}
+                total_sizes_dict_rule = {}
+                try:
+                    total_sizes = result['o']["ou"]["v"]
+                    total_sizes_big_rule, total_sizes_big, total_sizes_small_rule, total_sizes_small = rangqiu_daxiao(inner=total_sizes)
+                    total_sizes_dict_rule["tnb"] = total_sizes_big_rule
+                    total_sizes_dict["tnb"] = total_sizes_big
+                    total_sizes_dict_rule["tns"] = total_sizes_small_rule
+                    total_sizes_dict["tns"] = total_sizes_small
+                except:
+                    total_sizes_dict_rule["tnb"] = ""
+                    total_sizes_dict["tnb"] = ""
+                    total_sizes_dict_rule["tns"] = ""
+                    total_sizes_dict["tns"] = ""
+                # 上半场总分大小
                 try:
-                    two_score_homes = score_home['o']["ouq2"]["v"]
-                    two_score_home_big_rule, two_score_home_big, two_score_home_small_rule, two_score_home_small = rangqiu_daxiao(
-                        inner=two_score_homes)
-                    team_scores_dict_rule["tbhb_2"] = two_score_home_big_rule
-                    team_scores_dict["tbhb_2"] = two_score_home_big
-                    team_scores_dict_rule["tbhs_2"] = two_score_home_small_rule
-                    team_scores_dict["tbhs_2"] = two_score_home_small
+                    half_total_sizes = result['o']["ou1st"]["v"]
+                    half_total_sizes_big_rule, half_total_sizes_big, half_total_sizes_small_rule, half_total_sizes_small = rangqiu_daxiao(
+                        inner=half_total_sizes)
+                    total_sizes_dict_rule["tnb_h"] = half_total_sizes_big_rule
+                    total_sizes_dict["tnb_h"] = half_total_sizes_big
+                    total_sizes_dict_rule["tns_h"] = half_total_sizes_small_rule
+                    total_sizes_dict["tns_h"] = half_total_sizes_small
                 except:
-                    team_scores_dict_rule["tbhb_2"] = ""
-                    team_scores_dict["tbhb_2"] = ""
-                    team_scores_dict_rule["tbhs_2"] = ""
-                    team_scores_dict["tbhs_2"] = ""
+                    total_sizes_dict_rule["tnb_h"] = ""
+                    total_sizes_dict["tnb_h"] = ""
+                    total_sizes_dict_rule["tns_h"] = ""
+                    total_sizes_dict["tns_h"] = ""
+                # 第一节总分大小
+                try:
+                    one_total_sizes = result['o']["ou1st"]["v"]
+                    one_total_sizes_big_rule, one_total_sizes_big, one_total_sizes_small_rule, one_total_sizes_small = rangqiu_daxiao(
+                        inner=one_total_sizes)
+                    total_sizes_dict_rule["tnb_1"] = one_total_sizes_big_rule
+                    total_sizes_dict["tnb_1"] = one_total_sizes_big
+                    total_sizes_dict_rule["tns_1"] = one_total_sizes_small_rule
+                    total_sizes_dict["tns_1"] = one_total_sizes_small
+                except:
+                    total_sizes_dict_rule["tnb_1"] = ""
+                    total_sizes_dict["tnb_1"] = ""
+                    total_sizes_dict_rule["tns_1"] = ""
+                    total_sizes_dict["tns_1"] = ""
+                # 第二节场总分大小
+                try:
+                    two_total_sizes = result['o']["ou2st"]["v"]
+                    two_total_sizes_big_rule, two_total_sizes_big, two_total_sizes_small_rule, two_total_sizes_small = rangqiu_daxiao(
+                        inner=two_total_sizes)
+                    total_sizes_dict_rule["tnb_2"] = two_total_sizes_big_rule
+                    total_sizes_dict["tnb_2"] = two_total_sizes_big
+                    total_sizes_dict_rule["tns_2"] = two_total_sizes_small_rule
+                    total_sizes_dict["tns_2"] = two_total_sizes_small
+                except:
+                    total_sizes_dict_rule["tnb_2"] = ""
+                    total_sizes_dict["tnb_2"] = ""
+                    total_sizes_dict_rule["tns_2"] = ""
+                    total_sizes_dict["tns_2"] = ""
+                # 第三节总分大小
+                try:
+                    three_total_sizes = result['o']["ou3st"]["v"]
+                    three_total_sizes_big_rule, three_total_sizes_big, three_total_sizes_small_rule, three_total_sizes_small = rangqiu_daxiao(
+                        inner=three_total_sizes)
+                    total_sizes_dict_rule["tnb_3"] = three_total_sizes_big_rule
+                    total_sizes_dict["tnb_3"] = three_total_sizes_big
+                    total_sizes_dict_rule["tns_3"] = three_total_sizes_small_rule
+                    total_sizes_dict["tns_3"] = three_total_sizes_small
+                except:
+                    total_sizes_dict_rule["tnb_3"] = ""
+                    total_sizes_dict["tnb_3"] = ""
+                    total_sizes_dict_rule["tns_3"] = ""
+                    total_sizes_dict["tns_3"] = ""
+                # 第四节总分大小
+                try:
+                    four_total_sizes = result['o']["ou4st"]["v"]
+                    four_total_sizes_big_rule, four_total_sizes_big, four_total_sizes_small_rule, four_total_sizes_small = rangqiu_daxiao(
+                        inner=four_total_sizes)
+                    total_sizes_dict_rule["tnb_4"] = four_total_sizes_big_rule
+                    total_sizes_dict["tnb_4"] = four_total_sizes_big
+                    total_sizes_dict_rule["tns_4"] = four_total_sizes_small_rule
+                    total_sizes_dict["tns_4"] = four_total_sizes_small
+                except:
+                    total_sizes_dict_rule["tnb_4"] = ""
+                    total_sizes_dict["tnb_4"] = ""
+                    total_sizes_dict_rule["tns_4"] = ""
+                    total_sizes_dict["tns_4"] = ""
+
+                # ----------------------------------------总分单双分割线------------------------------------------------------------------
+                # 全场 总分单双
+                odd_evens_dict = {}
+                odd_evens_dict_rule = {}
+                try:
+                    odd_evens = result['o']["oe"]["v"]
+                    # 全场 总分单, 全场 总分双
+                    odd_evens_dict["tss"] = odd_evens[1]
+                    odd_evens_dict_rule['tss'] = '单'
+                    odd_evens_dict["tsd"] = odd_evens[3]
+                    odd_evens_dict_rule['tsd'] = '双'
+                except:
+                    odd_evens_dict["tss"] = ""
+                    odd_evens_dict_rule['tss'] = '单'
+                    odd_evens_dict["tsd"] = ""
+                    odd_evens_dict_rule['tsd'] = '双'
+                # 上半场全场 总分单双
 
-                # 球队得分:主队-大 / 小-第三节
                 try:
-                    three_score_homes = score_home['o']["ouq3"]["v"]
-                    three_score_home_big_rule, three_score_home_big, three_score_home_small_rule, three_score_home_small = rangqiu_daxiao(
-                        inner=three_score_homes)
-                    team_scores_dict_rule["tbhb_3"] = three_score_home_big_rule
-                    team_scores_dict["tbhb_3"] = three_score_home_big
-                    team_scores_dict_rule["tbhs_3"] = three_score_home_small_rule
-                    team_scores_dict["tbhs_3"] = three_score_home_small
+                    half_odd_evens = result['o']["oe1st"]["v"]
+                    # 上半场 总分单, 上半场 总分双
+                    odd_evens_dict["tss_h"] = half_odd_evens[1]
+                    odd_evens_dict_rule['tss_h'] = '单'
+                    odd_evens_dict["tsd_h"] = half_odd_evens[3]
+                    odd_evens_dict_rule['tsd_h'] = '双'
                 except:
-                    team_scores_dict_rule["tbhb_3"] = ""
-                    team_scores_dict["tbhb_3"] = ""
-                    team_scores_dict_rule["tbhs_3"] = ""
-                    team_scores_dict["tbhs_3"] = ""
+                    # half_odd_even_odd = ""
+                    # half_odd_even_even = ""
+                    odd_evens_dict["tss_h"] = ""
+                    odd_evens_dict_rule['tss_h'] = '单'
+                    odd_evens_dict["tsd_h"] = ""
+                    odd_evens_dict_rule['tsd_h'] = '双'
+
+                # 总分:单/双-第一节
+                try:
+                    one_odd_evens = result['o']["oeq1"]["v"]
+                    odd_evens_dict["tss_1"] = one_odd_evens[1]
+                    odd_evens_dict_rule['tss_1'] = '单'
+                    odd_evens_dict["tsd_1"] = one_odd_evens[3]
+                    odd_evens_dict_rule['tsd_1'] = '双'
+                except:
+                    odd_evens_dict["tss_1"] = ""
+                    odd_evens_dict_rule['tss_1'] = '单'
+                    odd_evens_dict["tsd_1"] = ""
+                    odd_evens_dict_rule['tsd_1'] = '双'
 
-                # 球队得分:主队-大 / 小-第四节
+                # 总分:单/双-第二节
                 try:
-                    four_score_homes = score_home['o']["ouq4"]["v"]
-                    four_score_home_big_rule, four_score_home_big, four_score_home_small_rule, four_score_home_small = rangqiu_daxiao(
-                        inner=four_score_homes)
-                    team_scores_dict_rule["tbhb_4"] = four_score_home_big_rule
-                    team_scores_dict["tbhb_4"] = four_score_home_big
-                    team_scores_dict_rule["tbhs_4"] = four_score_home_small_rule
-                    team_scores_dict["tbhs_4"] = four_score_home_small
+                    two_odd_evens = result['o']["oeq2"]["v"]
+                    odd_evens_dict["tss_2"] = two_odd_evens[1]
+                    odd_evens_dict_rule['tss_2'] = '单'
+                    odd_evens_dict["tsd_2"] = two_odd_evens[3]
+                    odd_evens_dict_rule['tsd_2'] = '双'
                 except:
-                    team_scores_dict_rule["tbhs_4"] = ""
-                    team_scores_dict["tbhb_4"] = ""
-                    team_scores_dict_rule["tbhs_4"] = ""
-                    team_scores_dict["tbhs_4"] = ""
-
-            # ---------------------------------------------------华丽分割线列表es[2]--------------------------------------------------
-            # 球队得分 客队 guest
-            try:
-                score_guest = new_data[2]
-            except:
-                score_guest = ""
-            if score_guest:
+                    # two_odd_even_odd = ""
+                    # two_odd_even_even = ""
+                    odd_evens_dict["tss_2"] = ""
+                    odd_evens_dict_rule['tss_2'] = '单'
+                    odd_evens_dict["tsd_2"] = ""
+                    odd_evens_dict_rule['tsd_2'] = '双'
+
+                # 总分:单/双-第三节
                 try:
-                    # 球队得分: 大 / 小
-                    score_guests = score_guest["o"]["ou"]['v']
-                    score_guest_big_rule, score_guest_big, score_guest_small_rule, score_guest_small = rangqiu_daxiao(inner=score_guests)
-                    team_scores_dict_rule["tbgb"] = score_guest_big_rule
-                    team_scores_dict["tbgb"] = score_guest_big
-                    team_scores_dict_rule["tbgs"] = score_guest_small_rule
-                    team_scores_dict["tbgs"] = score_guest_small
+                    three_odd_evens = result['o']["oeq3"]["v"]
+                    odd_evens_dict["tss_3"] = three_odd_evens[1]
+                    odd_evens_dict_rule['tss_3'] = '单'
+                    odd_evens_dict["tsd_3"] = three_odd_evens[3]
+                    odd_evens_dict_rule['tsd_3'] = '双'
                 except:
-                    team_scores_dict_rule["tbgb"] = ""
-                    team_scores_dict["tbgb"] = ""
-                    team_scores_dict_rule["tbgs"] = ""
-                    team_scores_dict["tbgs"] = ""
+                    odd_evens_dict["tss_3"] = ""
+                    odd_evens_dict_rule['tss_3'] = '单'
+                    odd_evens_dict["tsd_3"] = ""
+                    odd_evens_dict_rule['tsd_3'] = '双'
 
-                # 球队得分 上半场客队 guest
+                # 总分:单/双-第四节
+                try:
+                    four_odd_evens = result['o']["oeq4"]["v"]
+                    odd_evens_dict["tss_4"] = four_odd_evens[1]
+                    odd_evens_dict_rule['tss_4'] = '单'
+                    odd_evens_dict["tsd_4"] = four_odd_evens[3]
+                    odd_evens_dict_rule['tsd_4'] = '双'
+                except:
+                    odd_evens_dict["tss_4"] = ""
+                    odd_evens_dict_rule['tss_4'] = '单'
+                    odd_evens_dict["tsd_4"] = ""
+                    odd_evens_dict_rule['tsd_4'] = '双'
+
+                # ----------------------------------------球队得分最后一位数分割线---------------------------------------------------------
+                # 球队得分最后一位数 主队
+                last_numbers_dict = {}
                 try:
-                    half_score_guests = score_guest["o"]['ou1st']['v']
-                    half_score_guest_big_rule, half_score_guest_big, half_score_guest_small_rule, half_score_guest_small = rangqiu_daxiao(
-                        inner=half_score_guests)
-                    team_scores_dict_rule["tbgb_h"] = half_score_guest_big_rule
-                    team_scores_dict["tbgb_h"] = half_score_guest_big
-                    team_scores_dict_rule["tbgs_h"] = half_score_guest_small_rule
-                    team_scores_dict["tbgs_h"] = half_score_guest_small
+                    last_numbers = result["p-o"][0]['o']
+                    last_home = {}
+                    for last_number in last_numbers:
+                        last_home[last_number[0]] = last_number[2]
                 except:
-                    team_scores_dict_rule["tbgb_h"] = ""
-                    team_scores_dict["tbgb_h"] = ""
-                    team_scores_dict_rule["tbgs_h"] = ""
-                    team_scores_dict["tbgs_h"] = ""
-                # 球队得分第一节
+                    last_home = {}
+                last_numbers_dict["last_home"] = last_home
+                # 球队得分最后一位数 客队
                 try:
-                    one_score_guests = score_guest["o"]['ouq1']['v']
-                    one_score_guest_big_rule, one_score_guest_big, one_score_guest_small_rule, one_score_guest_small = rangqiu_daxiao(
-                        inner=one_score_guests)
-                    team_scores_dict_rule["tbgb_1"] = one_score_guest_big_rule
-                    team_scores_dict["tbgb_1"] = one_score_guest_big
-                    team_scores_dict_rule["tbgs_1"] = one_score_guest_small_rule
-                    team_scores_dict["tbgs_1"] = one_score_guest_small
+                    new_last_numbers = result["p-o"][1]['o']
+                    last_guest = {}
+                    for new_last_number in new_last_numbers:
+                        last_guest[new_last_number[0]] = new_last_number[2]
                 except:
-                    team_scores_dict_rule["tbgb_1"] = ""
-                    team_scores_dict["tbgb_1"] = ""
-                    team_scores_dict_rule["tbgs_1"] = ""
-                    team_scores_dict["tbgs_1"] = ""
+                    last_guest = {}
+                last_numbers_dict["last_guest"] = last_guest
+                # ------------------------------------------------------独赢分割线---------------------------------------------------------
+                capots_dict = {}
+                # 独赢
+                try:
+                    capots = result['o']["ml"]["v"]
+                    capot_list = [capots[i] for i in range(len(capots)) if i % 2 == 1]
+                    capot_home = capot_list[0]
+                    capot_guest = capot_list[1]
+                    capots_dict["ch"] = capot_home
+                    capots_dict["cg"] = capot_guest
+                except:
+                    capots_dict["ch"] = ""
+                    capots_dict["cg"] = ""
 
-                # 球队得分第二节
+                # 上半场独赢
                 try:
-                    two_score_guests = score_guest["o"]['ouq2']['v']
-                    two_score_guest_big_rule, two_score_guest_big, two_score_guest_small_rule, two_score_guest_small = rangqiu_daxiao(
-                        inner=two_score_guests)
-                    team_scores_dict_rule["tbgb_2"] = two_score_guest_big_rule
-                    team_scores_dict["tbgb_2"] = two_score_guest_big
-                    team_scores_dict_rule["tbgs_2"] = two_score_guest_small_rule
-                    team_scores_dict["tbgs_2"] = two_score_guest_small
+                    half_capots = result['o']["ml1st"]["v"]
+                    half_capot_list = [half_capots[i] for i in range(len(half_capots)) if i % 2 == 1]
+                    half_capot_home = half_capot_list[0]
+                    half_capot_guest = half_capot_list[1]
+                    capots_dict["ch_h"] = half_capot_home
+                    capots_dict["cg_h"] = half_capot_guest
                 except:
-                    team_scores_dict_rule["tbgb_2"] = ""
-                    team_scores_dict["tbgb_2"] = ""
-                    team_scores_dict_rule["tbgs_2"] = ""
-                    team_scores_dict["tbgs_2"] = ""
-                # 球队得分第三节
+                    capots_dict["ch_h"] = ""
+                    capots_dict["cg_h"] = ""
+
+                # 第一节独赢
                 try:
-                    three_score_guests = score_guest["o"]['ouq3']['v']
-                    three_score_guest_big_rule, three_score_guest_big, three_score_guest_small_rule, three_score_guest_small = rangqiu_daxiao(
-                        inner=three_score_guests)
-                    team_scores_dict_rule["tbgb_3"] = three_score_guest_big_rule
-                    team_scores_dict["tbgb_3"] = three_score_guest_big
-                    team_scores_dict_rule["tbgs_3"] = three_score_guest_small_rule
-                    team_scores_dict["tbgs_3"] = three_score_guest_small
+                    one_capots = result['o']["mlq1"]["v"]
+                    one_capot_list = [one_capots[i] for i in range(len(one_capots)) if i % 2 == 1]
+                    one_capot_home = one_capot_list[0]
+                    one_capot_guest = one_capot_list[1]
+                    capots_dict["ch_1"] = one_capot_home
+                    capots_dict["cg_1"] = one_capot_guest
                 except:
-                    team_scores_dict_rule["tbgb_3"] = ""
-                    team_scores_dict["tbgb_3"] = ""
-                    team_scores_dict_rule["tbgs_3"] = ""
-                    team_scores_dict["tbgs_3"] = ""
-                # 球队得分第四节
+                    capots_dict["ch_1"] = ""
+                    capots_dict["cg_1"] = ""
+
+                # 第二节独赢
                 try:
-                    four_score_guests = score_guest["o"]['ouq4']['v']
-                    four_score_guest_big_rule, four_score_guest_big, four_score_guest_small_rule, four_score_guest_small = rangqiu_daxiao(
-                        inner=four_score_guests)
-                    team_scores_dict_rule["tbgb_4"] = four_score_guest_big_rule
-                    team_scores_dict["tbgb_4"] = four_score_guest_big
-                    team_scores_dict_rule["tbgs_4"] = four_score_guest_small_rule
-                    team_scores_dict["tbgs_4"] = four_score_guest_small
+                    two_capots = result['o']["mlq2"]["v"]
+                    two_capot_list = [two_capots[i] for i in range(len(two_capots)) if i % 2 == 1]
+                    two_capot_home = two_capot_list[0]
+                    two_capot_guest = two_capot_list[1]
+                    capots_dict["ch_2"] = two_capot_home
+                    capots_dict["cg_2"] = two_capot_guest
                 except:
-                    team_scores_dict_rule["tbgb_4"] = ""
-                    team_scores_dict["tbgb_4"] = ""
-                    team_scores_dict_rule["tbgs_4"] = ""
-                    team_scores_dict["tbgs_4"] = ""
+                    capots_dict["ch_2"] = ""
+                    capots_dict["cg_2"] = ""
 
-            # 联赛id
-            item['league_id'] = league_id
-            # 联赛名
-            item['league_name'] = league_name
-            # item['result'] = result
-            # 比赛id
-            item['game_id'] = game_id
-            # 球队1
-            item['team_home'] = team_home
-            # 球队2
-            item['team_guest'] = team_guest
-            # 数量(97>)
-            item['number'] = number
-            # 比赛状态
-            item['zhuangtai'] = zhuangtai
-            # 日期
-            item['data_game'] = data_game
-            # 开赛时间
-            item['time_game'] = time_game
-            # 队1分数
-            item['score_home'] = score_home1
-            # 队2分数
-            item['score_guest'] = score_guest1
-            # 第几节
-            item['jijie'] = jijie
-            # 球队得分
-            item['qiudui'] = qiudui
-            item['concede'] = concedes_dict
-            item['concede_rule'] = concedes_dict_rule
-            item['odd_even'] = odd_evens_dict
-            item['odd_even_rule'] = odd_evens_dict_rule
-            item['total_size'] = total_sizes_dict
-            item['total_size_rule'] = total_sizes_dict_rule
-            item['last_number'] = last_numbers_dict
-            item['capot'] = capots_dict
-            item['team_score'] = team_scores_dict
-            item['team_score_rule'] = team_scores_dict_rule
-            yield item
+                # 第三节独赢
+                try:
+                    three_capots = result['o']["mlq3"]["v"]
+                    three_capot_list = [three_capots[i] for i in range(len(three_capots)) if i % 2 == 1]
+                    three_capot_home = three_capot_list[0]
+                    three_capot_guest = three_capot_list[1]
+                    capots_dict["ch_3"] = three_capot_home
+                    capots_dict["cg_3"] = three_capot_guest
+                except:
+                    capots_dict["ch_3"] = ""
+                    capots_dict["cg_3"] = ""
+
+                # 第四节独赢
+                try:
+                    four_capots = result['o']["mlq2"]["v"]
+                    four_capot_list = [four_capots[i] for i in range(len(four_capots)) if i % 2 == 1]
+                    four_capot_home = four_capot_list[0]
+                    four_capot_guest = four_capot_list[1]
+                    capots_dict["ch_4"] = four_capot_home
+                    capots_dict["cg_4"] = four_capot_guest
+                except:
+                    capots_dict["ch_4"] = ""
+                    capots_dict["cg_4"] = ""
+
+                # ---------------------------------------------------华丽分割线列表es[1]--------------------------------------------------
+                # 球队得分大/小 全场主队 home
+                team_scores_dict = {}
+                team_scores_dict_rule = {}
+                try:
+                    score_home = new_data[1]
+                except:
+                    score_home = ""
+                if score_home:
+                    try:
+                        score_homes = score_home["o"]["ou"]['v']
+                        score_home_big_rule, score_home_big, score_home_small_rule, score_home_small = rangqiu_daxiao(inner=score_homes)
+                        team_scores_dict_rule["tbhb"] = score_home_big_rule
+                        team_scores_dict["tbhb"] = score_home_big
+                        team_scores_dict_rule["tbhs"] = score_home_small_rule
+                        team_scores_dict["tbhs"] = score_home_small
+                    except:
+                        team_scores_dict_rule["tbhb"] = ""
+                        team_scores_dict["tbhb"] = ""
+                        team_scores_dict_rule["tbhs"] = ""
+                        team_scores_dict["tbhs"] = ""
+                    # 球队得分 上半场主队 home
+                    try:
+                        half_score_homes = score_home['o']['ou1st']['v']
+                        # 球队得分 上半场主队 大条件
+                        half_score_home_big_rule, half_score_home_big, half_score_home_small_rule, half_score_home_small = rangqiu_daxiao(
+                            inner=half_score_homes)
+                        team_scores_dict_rule["tbhb_h"] = half_score_home_big_rule
+                        team_scores_dict["tbhb_h"] = half_score_home_big
+                        team_scores_dict_rule["tbhs_h"] = half_score_home_small_rule
+                        team_scores_dict["tbhs_h"] = half_score_home_small
+                    except:
+                        team_scores_dict_rule["tbhb_h"] = ""
+                        team_scores_dict["tbhb_h"] = ""
+                        team_scores_dict_rule["tbhs_h"] = ""
+                        team_scores_dict["tbhs_h"] = ""
+
+                    # 球队得分:主队-大 / 小-第一节
+                    try:
+                        one_score_homes = score_home['o']["ouq1"]["v"]
+                        one_score_home_big_rule, one_score_home_big, one_score_home_small_rule, one_score_home_small = rangqiu_daxiao(
+                            inner=one_score_homes)
+                        team_scores_dict_rule["tbhb_1"] = one_score_home_big_rule
+                        team_scores_dict["tbhb_1"] = one_score_home_big
+                        team_scores_dict_rule["tbhs_1"] = one_score_home_small_rule
+                        team_scores_dict["tbhs_1"] = one_score_home_small
+                    except:
+                        team_scores_dict_rule["tbhb_1"] = ""
+                        team_scores_dict["tbhb_1"] = ""
+                        team_scores_dict_rule["tbhs_1"] = ""
+                        team_scores_dict["tbhs_1"] = ""
+
+                    # 球队得分:主队-大 / 小-第二节
+                    try:
+                        two_score_homes = score_home['o']["ouq2"]["v"]
+                        two_score_home_big_rule, two_score_home_big, two_score_home_small_rule, two_score_home_small = rangqiu_daxiao(
+                            inner=two_score_homes)
+                        team_scores_dict_rule["tbhb_2"] = two_score_home_big_rule
+                        team_scores_dict["tbhb_2"] = two_score_home_big
+                        team_scores_dict_rule["tbhs_2"] = two_score_home_small_rule
+                        team_scores_dict["tbhs_2"] = two_score_home_small
+                    except:
+                        team_scores_dict_rule["tbhb_2"] = ""
+                        team_scores_dict["tbhb_2"] = ""
+                        team_scores_dict_rule["tbhs_2"] = ""
+                        team_scores_dict["tbhs_2"] = ""
+
+                    # 球队得分:主队-大 / 小-第三节
+                    try:
+                        three_score_homes = score_home['o']["ouq3"]["v"]
+                        three_score_home_big_rule, three_score_home_big, three_score_home_small_rule, three_score_home_small = rangqiu_daxiao(
+                            inner=three_score_homes)
+                        team_scores_dict_rule["tbhb_3"] = three_score_home_big_rule
+                        team_scores_dict["tbhb_3"] = three_score_home_big
+                        team_scores_dict_rule["tbhs_3"] = three_score_home_small_rule
+                        team_scores_dict["tbhs_3"] = three_score_home_small
+                    except:
+                        team_scores_dict_rule["tbhb_3"] = ""
+                        team_scores_dict["tbhb_3"] = ""
+                        team_scores_dict_rule["tbhs_3"] = ""
+                        team_scores_dict["tbhs_3"] = ""
+
+                    # 球队得分:主队-大 / 小-第四节
+                    try:
+                        four_score_homes = score_home['o']["ouq4"]["v"]
+                        four_score_home_big_rule, four_score_home_big, four_score_home_small_rule, four_score_home_small = rangqiu_daxiao(
+                            inner=four_score_homes)
+                        team_scores_dict_rule["tbhb_4"] = four_score_home_big_rule
+                        team_scores_dict["tbhb_4"] = four_score_home_big
+                        team_scores_dict_rule["tbhs_4"] = four_score_home_small_rule
+                        team_scores_dict["tbhs_4"] = four_score_home_small
+                    except:
+                        team_scores_dict_rule["tbhs_4"] = ""
+                        team_scores_dict["tbhb_4"] = ""
+                        team_scores_dict_rule["tbhs_4"] = ""
+                        team_scores_dict["tbhs_4"] = ""
+
+                # ---------------------------------------------------华丽分割线列表es[2]--------------------------------------------------
+                # 球队得分 客队 guest
+                try:
+                    score_guest = new_data[2]
+                except:
+                    score_guest = ""
+                if score_guest:
+                    try:
+                        # 球队得分: 大 / 小
+                        score_guests = score_guest["o"]["ou"]['v']
+                        score_guest_big_rule, score_guest_big, score_guest_small_rule, score_guest_small = rangqiu_daxiao(inner=score_guests)
+                        team_scores_dict_rule["tbgb"] = score_guest_big_rule
+                        team_scores_dict["tbgb"] = score_guest_big
+                        team_scores_dict_rule["tbgs"] = score_guest_small_rule
+                        team_scores_dict["tbgs"] = score_guest_small
+                    except:
+                        team_scores_dict_rule["tbgb"] = ""
+                        team_scores_dict["tbgb"] = ""
+                        team_scores_dict_rule["tbgs"] = ""
+                        team_scores_dict["tbgs"] = ""
+
+                    # 球队得分 上半场客队 guest
+                    try:
+                        half_score_guests = score_guest["o"]['ou1st']['v']
+                        half_score_guest_big_rule, half_score_guest_big, half_score_guest_small_rule, half_score_guest_small = rangqiu_daxiao(
+                            inner=half_score_guests)
+                        team_scores_dict_rule["tbgb_h"] = half_score_guest_big_rule
+                        team_scores_dict["tbgb_h"] = half_score_guest_big
+                        team_scores_dict_rule["tbgs_h"] = half_score_guest_small_rule
+                        team_scores_dict["tbgs_h"] = half_score_guest_small
+                    except:
+                        team_scores_dict_rule["tbgb_h"] = ""
+                        team_scores_dict["tbgb_h"] = ""
+                        team_scores_dict_rule["tbgs_h"] = ""
+                        team_scores_dict["tbgs_h"] = ""
+                    # 球队得分第一节
+                    try:
+                        one_score_guests = score_guest["o"]['ouq1']['v']
+                        one_score_guest_big_rule, one_score_guest_big, one_score_guest_small_rule, one_score_guest_small = rangqiu_daxiao(
+                            inner=one_score_guests)
+                        team_scores_dict_rule["tbgb_1"] = one_score_guest_big_rule
+                        team_scores_dict["tbgb_1"] = one_score_guest_big
+                        team_scores_dict_rule["tbgs_1"] = one_score_guest_small_rule
+                        team_scores_dict["tbgs_1"] = one_score_guest_small
+                    except:
+                        team_scores_dict_rule["tbgb_1"] = ""
+                        team_scores_dict["tbgb_1"] = ""
+                        team_scores_dict_rule["tbgs_1"] = ""
+                        team_scores_dict["tbgs_1"] = ""
+
+                    # 球队得分第二节
+                    try:
+                        two_score_guests = score_guest["o"]['ouq2']['v']
+                        two_score_guest_big_rule, two_score_guest_big, two_score_guest_small_rule, two_score_guest_small = rangqiu_daxiao(
+                            inner=two_score_guests)
+                        team_scores_dict_rule["tbgb_2"] = two_score_guest_big_rule
+                        team_scores_dict["tbgb_2"] = two_score_guest_big
+                        team_scores_dict_rule["tbgs_2"] = two_score_guest_small_rule
+                        team_scores_dict["tbgs_2"] = two_score_guest_small
+                    except:
+                        team_scores_dict_rule["tbgb_2"] = ""
+                        team_scores_dict["tbgb_2"] = ""
+                        team_scores_dict_rule["tbgs_2"] = ""
+                        team_scores_dict["tbgs_2"] = ""
+                    # 球队得分第三节
+                    try:
+                        three_score_guests = score_guest["o"]['ouq3']['v']
+                        three_score_guest_big_rule, three_score_guest_big, three_score_guest_small_rule, three_score_guest_small = rangqiu_daxiao(
+                            inner=three_score_guests)
+                        team_scores_dict_rule["tbgb_3"] = three_score_guest_big_rule
+                        team_scores_dict["tbgb_3"] = three_score_guest_big
+                        team_scores_dict_rule["tbgs_3"] = three_score_guest_small_rule
+                        team_scores_dict["tbgs_3"] = three_score_guest_small
+                    except:
+                        team_scores_dict_rule["tbgb_3"] = ""
+                        team_scores_dict["tbgb_3"] = ""
+                        team_scores_dict_rule["tbgs_3"] = ""
+                        team_scores_dict["tbgs_3"] = ""
+                    # 球队得分第四节
+                    try:
+                        four_score_guests = score_guest["o"]['ouq4']['v']
+                        four_score_guest_big_rule, four_score_guest_big, four_score_guest_small_rule, four_score_guest_small = rangqiu_daxiao(
+                            inner=four_score_guests)
+                        team_scores_dict_rule["tbgb_4"] = four_score_guest_big_rule
+                        team_scores_dict["tbgb_4"] = four_score_guest_big
+                        team_scores_dict_rule["tbgs_4"] = four_score_guest_small_rule
+                        team_scores_dict["tbgs_4"] = four_score_guest_small
+                    except:
+                        team_scores_dict_rule["tbgb_4"] = ""
+                        team_scores_dict["tbgb_4"] = ""
+                        team_scores_dict_rule["tbgs_4"] = ""
+                        team_scores_dict["tbgs_4"] = ""
+                # 篮球详细比分
+                score_dict = {}
+                try:
+                    # 当前节
+                    score_dict['schedule'] = result['sb']['cp']
+                    # 时间
+                    score_dict['r_time'] = result['sb']['ct']
+                    # 	"sc_1th_H": "15", //第一节 主队得分
+                    # 	"sc_1th_C": "16", //第一节 客队得分
+                    score_dict['sc_1th_H'] = result['sb']['ps'][2]['h']
+                    score_dict['sc_1th_C'] = result['sb']['ps'][2]['a']
+                    score_dict['sc_2th_H'] = result['sb']['ps'][3]['h']
+                    score_dict['sc_2th_C'] = result['sb']['ps'][3]['a']
+                    score_dict['sc_3th_H'] = result['sb']['ps'][4]['h']
+                    score_dict['sc_3th_C'] = result['sb']['ps'][4]['a']
+                    score_dict['sc_4th_H'] = result['sb']['ps'][5]['h']
+                    score_dict['sc_4th_C'] = result['sb']['ps'][5]['a']
+                    score_dict['overtime_H'] = result['sb']['ps'][7]['h']
+                    score_dict['overtime_C'] = result['sb']['ps'][7]['a']
+                    score_dict['half_H'] = result['sb']['ps'][0]['h']
+                    score_dict['half_C'] = result['sb']['ps'][0]['a']
+                    score_dict['full_H'] = result['sb']['ps'][6]['h']
+                    score_dict['full_C'] = result['sb']['ps'][6]['a']
+                    score_dict['whole_H'] = result['sb']['ps'][1]['h']
+                    score_dict['whole_C'] = result['sb']['ps'][1]['a']
+                except:
+                    pass
+
+                # 联赛id
+                item['league_id'] = league_id
+                # 联赛名
+                item['league_name'] = league_name
+                # item['result'] = result
+                # 比赛id
+                item['game_id'] = game_id
+                # 球队1
+                item['team_home'] = team_home
+                # 球队2
+                item['team_guest'] = team_guest
+                # 数量(97>)
+                item['number'] = number
+                # 比赛状态
+                item['zhuangtai'] = zhuangtai
+                # 日期
+                item['data_game'] = data_game
+                # 开赛时间
+                item['time_game'] = time_game
+                # 队1分数
+                item['score_home'] = score_home1
+                # 队2分数
+                item['score_guest'] = score_guest1
+                # 第几节
+                item['jijie'] = jijie
+                # 球队得分
+                item['qiudui'] = qiudui
+                item['concede'] = concedes_dict
+                item['concede_rule'] = concedes_dict_rule
+                item['odd_even'] = odd_evens_dict
+                item['odd_even_rule'] = odd_evens_dict_rule
+                item['total_size'] = total_sizes_dict
+                item['total_size_rule'] = total_sizes_dict_rule
+                item['last_number'] = last_numbers_dict
+                item['capot'] = capots_dict
+                item['team_score'] = team_scores_dict
+                item['team_score_rule'] = team_scores_dict_rule
+                item['score_dict'] = score_dict
+                yield item

+ 85 - 43
hg3535/spiders/roll_wangqiu.py

@@ -60,22 +60,22 @@ class WangqiuSpider(scrapy.Spider):
         datas = json.loads(response.text)
         # item = Today_all()
         ids = jsonpath.jsonpath(datas, '$..i-ot[0]..egs..es..i[16]')  # ids新列表
+        rules = jsonpath.jsonpath(datas, '$..i-ot[0]..egs..es..i[19]')
         # print(ids)
         if ids:
-            ids = set(ids)
-            for i in ids:
+            # ids = set(ids)
+            for index, id in enumerate(ids):
                 # urls = 'https://www.hg3535z.com/odds2/d/getamodds?eid={}&iip=true&ubt=am&isp=false'.format(i)
                 urls = 'https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/true/ubt/am/isp/false'.format(
-                    i)
+                    id)
+                # 玩法规则
+                rle = rules[index]
                 # print(urls)
-                yield Request(url=urls, callback=self.parse_other, dont_filter=True)
+                yield Request(url=urls, callback=self.parse_other, meta={'rule': rle}, dont_filter=True)
 
     def parse_other(self, response):
         new_datas = json.loads(response.text).get('eg', "")
-        try:
-            pt = response.meta['pt']
-        except:
-            pt = 0
+        rule = response.meta['rule']
         item = Roll_Wangqiu()
         if new_datas:
             # 联赛id
@@ -145,7 +145,7 @@ class WangqiuSpider(scrapy.Spider):
                     concedes_dict_rule['one_dishes_guest'] = ""
                     concedes_dict['one_dishes_guest'] = ""
 
-                # ----------------------------------------第二节让球分割线----------------------------------------------------------------
+                # ----------------------------------------第二节让球分割线-------------------------------------------------
 
                 # 第二节让盘
                 try:
@@ -160,7 +160,7 @@ class WangqiuSpider(scrapy.Spider):
                     concedes_dict_rule['two_dishes_guest'] = ""
                     concedes_dict['two_dishes_guest'] = ""
 
-                # ---------------------------------------------------冠军  滚球是独赢-----------------------------------------------------
+                # ---------------------------------------------------冠军  滚球是独赢--------------------------------------
                 kemps_dict = {}
                 try:
                     # 滚球独赢
@@ -189,7 +189,7 @@ class WangqiuSpider(scrapy.Spider):
                     kemps_dict['ch_2'] = ""
                     kemps_dict["cg_2"] = ""
 
-                # ---------------------------------------------------让局---------------------------------------------------------------
+                # ---------------------------------------------------让局------------------------------------------------
 
                 bureaus_dict = {}
                 bureaus_dict_rule = {}
@@ -204,8 +204,7 @@ class WangqiuSpider(scrapy.Spider):
                     bureaus_dict['lbh'] = ""
                     bureaus_dict_rule['lbg'] = ""
                     bureaus_dict['lbg'] = ""
-
-                # -----------------------------------------------------总局数 第一盘:大/小------------------------------------------------
+                # -----------------------------------------------------总局数 第一盘:大/小---------------------------------
                 total_number_dict = {}
                 total_number_dict_rule = {}
                 try:  # 总局数 滚球大小
@@ -259,7 +258,7 @@ class WangqiuSpider(scrapy.Spider):
                     total_number_dict_rule["tns_3"] = ""
                     total_number_dict["tns_3"] = ""
 
-                # ------------------------------------------------------总局数:单/双-----------------------------------------------------
+                # ------------------------------------------------------总局数:单/双--------------------------------------
                 odd_evens_dict = {}
                 odd_evens_dict_rule = {}
                 try:
@@ -289,36 +288,79 @@ class WangqiuSpider(scrapy.Spider):
                     h = result['sb']['h']
                     # 队伍2 当前的大比分
                     a = result['sb']['a']
-                    for cp in cps:
-                        # 当前比分
-                        if cp['p'] == 'p':
-                            score_dict['current_point_home_guest'] = str(cp['h']) + ':' + str(cp['a'])
-                        # 每局比分
-                        if cp['p'] == 's1':
-                            score_dict['one_score'] = str(cp['h']) + '-' + str(cp['a'])
-                        elif cp['p'] == 's2':
-                            score_dict['second_score'] = str(cp['h']) + '-' + str(cp['a'])
-                        elif cp['p'] == 's3':
-                            score_dict['third_score'] = str(cp['h']) + '-' + str(cp['a'])
-                        elif cp['p'] == 's4':
-                            score_dict['four_score'] = str(cp['h']) + '-' + str(cp['a'])
-                        elif cp['p'] == 's5':
-                            score_dict['five_score'] = str(cp['h']) + '-' + str(cp['a'])
-                        elif cp['p'] == 'ftg':
-                            score_dict['total_inning'] = int(cp['h']) + int(cp['a'])
-                        cp.pop('e')
-                        cp.pop('adv')
-                        cp['cp'] = s
-                        saiqing.append(cp)
-                    sq_dict['ps'] = saiqing
+                    score_dict['schedule'] = s
+                    score_dict['sc_1th_H'] = cps[1]['h']
+                    score_dict['sc_1th_C'] = cps[1]['a']
+                    score_dict['sc_2th_H'] = cps[2]['h']
+                    score_dict['sc_2th_C'] = cps[2]['a']
+                    score_dict['sc_3th_H'] = cps[3]['h']
+                    score_dict['sc_3th_C'] = cps[3]['a']
+                    score_dict['sc_4th_H'] = cps[4]['h']
+                    score_dict['sc_4th_C'] = cps[4]['a']
+                    score_dict['sc_5th_H'] = cps[7]['h']
+                    score_dict['sc_5th_C'] = cps[7]['a']
+                    score_dict['disc_H'] = cps[0]['h']
+                    score_dict['disc_C'] = cps[0]['a']
+                    score_dict['spot_H'] = cps[6]['h']
+                    score_dict['spot_C'] = cps[6]['a']
+                    score_dict['game_num_H'] = cps[5]['h']
+                    score_dict['game_num_C'] = cps[5]['a']
+                    score_dict["showdelay"] = ''
+                    score_dict['best'] = rule
+
+                    # a = {
+                    #     "schedule": "第三节",
+                    #     "sc_1th_H": "7",
+                    #     "sc_1th_C": "5",
+                    #     "sc_2th_H": "4",
+                    #     "sc_2th_C": "6",
+                    #     "sc_3th_H": "6",
+                    #     "sc_3th_C": "6",
+                    #     "sc_4th_H": "",
+                    #     "sc_4th_C": "",
+                    #     "sc_5th_H": "",
+                    #     "sc_5th_C": "",
+                    #     "disc_H": "1",
+                    #     "disc_C": "1",
+                    #     "spot_H": "4",
+                    #     "spot_C": "1",
+                    #     "game_num_H": "17",
+                    #     "game_num_C": "17",
+                    #     "best": "Best of 3",
+                    #     "showdelay": "N"
+                    # }
+
+                    # for cp in cps:
+                    #     # 当前比分
+                    #     if cp['p'] == 'p':
+                    #         score_dict['current_point_home_guest'] = str(cp['h']) + ':' + str(cp['a'])
+                    #     # 每局比分
+                    #     if cp['p'] == 's1':
+                    #         score_dict['one_score'] = str(cp['h']) + '-' + str(cp['a'])
+                    #     elif cp['p'] == 's2':
+                    #         score_dict['second_score'] = str(cp['h']) + '-' + str(cp['a'])
+                    #     elif cp['p'] == 's3':
+                    #         score_dict['third_score'] = str(cp['h']) + '-' + str(cp['a'])
+                    #     elif cp['p'] == 's4':
+                    #         score_dict['four_score'] = str(cp['h']) + '-' + str(cp['a'])
+                    #     elif cp['p'] == 's5':
+                    #         score_dict['five_score'] = str(cp['h']) + '-' + str(cp['a'])
+                    #     elif cp['p'] == 'ftg':
+                    #         score_dict['total_inning'] = int(cp['h']) + int(cp['a'])
+                    #     cp.pop('e')
+                    #     cp.pop('adv')
+                    #     cp['cp'] = s
+                    #     saiqing.append(cp)
+                    # sq_dict['ps'] = saiqing
                     # print(sq_dict)
                 except:
-                    sq_dict['ps'] = None
-                    # 队伍1
-                    h = 0
-                    # 队伍2
-                    a = 0
-                    s = 0
+                    pass
+                    # sq_dict['ps'] = None
+                    # # 队伍1
+                    # h = 0
+                    # # 队伍2
+                    # a = 0
+                    # s = 0
                 # 联赛id
                 item['league_id'] = league_id
                 # 联赛名
@@ -343,7 +385,6 @@ class WangqiuSpider(scrapy.Spider):
                 item['score_guest'] = a
                 # 当前第几节
                 item['jijie'] = s
-                item['pt'] = pt
                 # 每局比分
                 item['score_dict'] = score_dict
                 # 球队得分
@@ -363,4 +404,5 @@ class WangqiuSpider(scrapy.Spider):
                 item['odd_evens_dict'] = odd_evens_dict
                 item['odd_evens_dict_rule'] = odd_evens_dict_rule
                 item['sq_dict'] = sq_dict
+                item['rule'] = rule
                 yield item

+ 5 - 2
hg3535/spiders/zuqiu.py

@@ -2,6 +2,7 @@
 import copy
 import json
 
+# import redis
 import scrapy
 from scrapy.http import Request
 from ..items import Zuqiu
@@ -37,6 +38,7 @@ class ZuqiuSpider(scrapy.Spider):
 
     def parse(self, response):
         if response.status == 200:
+            # cls = redis.Redis(host='192.168.0.110', port=6379, db=0)
             if response.text:
                 try:
                     datas = json.loads(response.text).get('n-ot', "").get('egs', "")
@@ -45,11 +47,12 @@ class ZuqiuSpider(scrapy.Spider):
                     print("为获取到数据")
                     return
                 pt = copy.copy(response.meta['pt'])
-
                 for result in datas:
                     new_results = result['es']
                     for new_result in new_results:
                         game_id = str(new_result['i'][16])
+                        # cls.sadd('hg3535.zq.ids', game_id)
+                        # cls.expire('hg3535.zq.ids', 300)
                         if pt == "3":
                             url = "https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/" + str(game_id) + "/iip/false/ubt/am/isp/true"
                             yield Request(url=url, callback=self.parse_each, dont_filter=True, meta={'pt': pt})
@@ -346,7 +349,7 @@ class ZuqiuSpider(scrapy.Spider):
                             bodan_guest = [new_bodan[i] for i in range(len(new_bodan)) if i % 2 is 1]
                             for y, z in enumerate(two_list):
                                 bodan_data[z] = round(float(bodan_guest[y]) - 1, 2)
-                            bodan_dogfall = new_bodans[-7:-2]
+                            bodan_dogfall = new_bodans[-6:-1]
                             for a, b in enumerate(three_list):
                                 bodan_data[b] = round(float(bodan_dogfall[a]) - 1, 2)
                             # 其他bodan_other

+ 1 - 1
hg3535/utils/helper.py

@@ -9,7 +9,7 @@ class Helper(object):
     def async_post(url, params):
         try:
             fs_session = FuturesSession()
-            data = fs_session.post(url, data={"data": json.dumps(params), "token": "u4Gdf015662654065d5b503ea2517"}, timeout=30).result()
+            data = fs_session.post(url, data={"data": json.dumps(params), "token": "u4Gdf015662654065d5b503ea2517"}, timeout=180).result()
             if data:
                 return data.content.decode('utf-8')
         except requests.exceptions.RequestException as e: