Your Name 6 years ago
parent
commit
433e63e5ab

+ 21 - 31
.idea/workspace.xml

@@ -3,10 +3,6 @@
   <component name="ChangeListManager">
     <list default="true" id="e65dd61d-6e54-407f-b262-e81360eb9ca1" 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$/hg3535/ball_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/hg3535/ball_func.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/hg3535/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/hg3535/main.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/hg3535/pipelines.py" beforeDir="false" afterPath="$PROJECT_DIR$/hg3535/pipelines.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/hg3535/spiders/roll_bangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/hg3535/spiders/roll_bangqiu.py" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
@@ -22,7 +18,7 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/hg3535/settings.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="402">
+            <state relative-caret-position="2700">
               <caret line="150" selection-start-line="150" selection-end-line="154" selection-end-column="26" />
             </state>
           </provider>
@@ -31,7 +27,7 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/hg3535/main.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="270">
+            <state relative-caret-position="234">
               <caret line="15" column="50" selection-start-line="15" selection-start-column="50" selection-end-line="15" selection-end-column="50" />
               <folding>
                 <element signature="e#0#10#0" expanded="true" />
@@ -43,7 +39,7 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/hg3535/ball_func.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="273">
+            <state relative-caret-position="7758">
               <caret line="433" column="132" selection-start-line="433" selection-start-column="124" selection-end-line="433" selection-end-column="132" />
               <folding>
                 <element signature="e#0#15#0" expanded="true" />
@@ -55,8 +51,8 @@
       <file pinned="false" current-in-tab="true">
         <entry file="file://$PROJECT_DIR$/hg3535/spiders/roll_bangqiu.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="-2556">
-              <caret line="31" lean-forward="true" selection-start-line="31" selection-end-line="31" />
+            <state relative-caret-position="18">
+              <caret line="31" selection-start-line="31" selection-end-line="31" />
             </state>
           </provider>
         </entry>
@@ -103,6 +99,7 @@
       <foldersAlwaysOnTop value="true" />
     </navigator>
     <panes>
+      <pane id="Scope" />
       <pane id="ProjectPane">
         <subPane>
           <expand>
@@ -115,22 +112,15 @@
               <item name="sports_scrapy" type="462c0819:PsiDirectoryNode" />
               <item name="hg3535" type="462c0819:PsiDirectoryNode" />
             </path>
-            <path>
-              <item name="sports_scrapy" type="b2602c69:ProjectViewProjectNode" />
-              <item name="sports_scrapy" type="462c0819:PsiDirectoryNode" />
-              <item name="hg3535" type="462c0819:PsiDirectoryNode" />
-              <item name="spiders" type="462c0819:PsiDirectoryNode" />
-            </path>
           </expand>
           <select />
         </subPane>
       </pane>
-      <pane id="Scope" />
     </panes>
   </component>
   <component name="PropertiesComponent">
     <property name="WebServerToolWindowFactoryState" value="false" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/hg3535" />
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
   </component>
@@ -194,6 +184,7 @@
       <workItem from="1560222787183" duration="141000" />
       <workItem from="1560317954184" duration="1442000" />
       <workItem from="1560394945986" duration="586000" />
+      <workItem from="1564469861451" duration="29000" />
     </task>
     <task id="LOCAL-00001" summary="更新">
       <created>1559729951030</created>
@@ -206,13 +197,12 @@
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="10556000" />
+    <option name="totallyTimeSpent" value="10585000" />
   </component>
   <component name="ToolWindowManager">
     <frame x="-8" y="-8" width="1936" height="1066" extended-state="6" />
-    <editor active="true" />
     <layout>
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1652452" />
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.16684435" />
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
       <window_info id="Favorites" order="2" side_tool="true" />
       <window_info anchor="bottom" id="Message" order="0" />
@@ -384,35 +374,35 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/hg3535/settings.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="402">
+        <state relative-caret-position="2700">
           <caret line="150" selection-start-line="150" selection-end-line="154" selection-end-column="26" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/hg3535/ball_func.py">
+    <entry file="file://$PROJECT_DIR$/hg3535/main.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="273">
-          <caret line="433" column="132" selection-start-line="433" selection-start-column="124" selection-end-line="433" selection-end-column="132" />
+        <state relative-caret-position="234">
+          <caret line="15" column="50" selection-start-line="15" selection-start-column="50" selection-end-line="15" selection-end-column="50" />
           <folding>
-            <element signature="e#0#15#0" expanded="true" />
+            <element signature="e#0#10#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/hg3535/main.py">
+    <entry file="file://$PROJECT_DIR$/hg3535/ball_func.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="270">
-          <caret line="15" column="50" selection-start-line="15" selection-start-column="50" selection-end-line="15" selection-end-column="50" />
+        <state relative-caret-position="7758">
+          <caret line="433" column="132" selection-start-line="433" selection-start-column="124" selection-end-line="433" selection-end-column="132" />
           <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$/hg3535/spiders/roll_bangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-2556">
-          <caret line="31" lean-forward="true" selection-start-line="31" selection-end-line="31" />
+        <state relative-caret-position="18">
+          <caret line="31" selection-start-line="31" selection-end-line="31" />
         </state>
       </provider>
     </entry>

+ 13 - 0
hg3535/.gitignore

@@ -0,0 +1,13 @@
+# Created by .ignore support plugin (hsz.mobi)
+*.o
+
+# Ada Library Information
+*.ali
+
+.gitignore
+log/
+pipeline/__pycache__/
+/__pycache__/
+spiders/__pycache__/
+.idea/
+utils/__pycache__/

+ 108 - 176
hg3535/.idea/workspace.xml

@@ -2,8 +2,42 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="7fa42e97-ddea-4404-91db-5a9ccc162649" name="Default Changelist" comment="">
+      <change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/not_roll.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/pipeline/ball_func.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/pipeline/guanjun.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/pipeline/lanqiu.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/pipeline/roll_lanqiu.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/pipeline/roll_zuqiu.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/pipeline/zuqiu.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/roll.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/utils/__init__.py" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/utils/helper.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/__init__.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ball_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/ball_func.py" 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$/main_time.py" beforeDir="false" afterPath="$PROJECT_DIR$/main_time.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/middlewares.py" beforeDir="false" afterPath="$PROJECT_DIR$/middlewares.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pipelines.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipelines.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/settings.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/__init__.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/bangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/bangqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/bq_jieshu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/bq_jieshu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/guanjun.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/guanjun.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/lanqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/lanqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/liansai.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/liansai.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/lq_jieshu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/lq_jieshu.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/roll_zuqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/roll_zuqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/wangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/wangqiu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/wq_jieshu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/wq_jieshu.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/wqbodan.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/wqbodan.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/zq_jieshu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/zq_jieshu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/spiders/zuqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/zuqiu.py" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -42,110 +76,35 @@
   </component>
   <component name="FileEditorManager">
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
-      <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="216">
-              <caret line="152" column="22" lean-forward="true" selection-start-line="152" selection-start-column="22" selection-end-line="152" selection-end-column="22" />
-            </state>
-          </provider>
-        </entry>
-      </file>
       <file pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/main.py">
+        <entry file="file://$PROJECT_DIR$/.gitignore">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="288">
-              <caret line="16" column="51" lean-forward="true" selection-start-line="16" selection-start-column="51" selection-end-line="16" selection-end-column="51" />
-              <folding>
-                <element signature="e#0#10#0" expanded="true" />
-              </folding>
+            <state relative-caret-position="180">
+              <caret line="10" column="20" lean-forward="true" selection-start-line="10" selection-start-column="20" selection-end-line="10" selection-end-column="20" />
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/pipelines.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="18">
-              <caret line="1742" column="34" selection-start-line="1742" selection-start-column="34" selection-end-line="1742" selection-end-column="34" />
-              <folding>
-                <element signature="e#0#11#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
+        <entry file="file://$PROJECT_DIR$/utils/helper.py">
+          <provider selected="true" editor-type-id="text-editor" />
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/main_time.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="144">
-              <caret line="11" selection-start-line="11" selection-end-line="11" />
-            </state>
-          </provider>
+        <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
+          <provider selected="true" editor-type-id="text-editor" />
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/spiders/zq_jieshu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="90">
-              <caret line="30" column="20" selection-start-line="30" selection-start-column="20" selection-end-line="30" selection-end-column="20" />
-              <folding>
-                <element signature="e#36#51#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/spiders/wq_jieshu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="630">
-              <caret line="54" column="94" selection-start-line="54" selection-start-column="94" selection-end-line="54" selection-end-column="94" />
-              <folding>
-                <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$/spiders/roll_zuqiu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="7038">
-              <caret line="399" column="59" selection-start-line="399" selection-start-column="59" selection-end-line="399" selection-end-column="59" />
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/spiders/wangqiu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="126">
-              <caret line="14" column="20" selection-start-line="14" selection-start-column="20" selection-end-line="14" selection-end-column="20" />
-            </state>
-          </provider>
+        <entry file="file://$PROJECT_DIR$/spiders/__init__.py">
+          <provider selected="true" editor-type-id="text-editor" />
         </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="162">
-              <caret line="21" selection-start-line="21" selection-end-line="22" selection-end-column="103" />
-              <folding>
-                <element signature="e#24#35#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/spiders/lanqiu.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="648">
-              <caret line="42" column="19" selection-start-line="42" selection-start-column="19" selection-end-line="42" selection-end-column="19" />
-              <folding>
-                <element signature="e#24#35#0" expanded="true" />
-              </folding>
+            <state relative-caret-position="-8370">
+              <caret line="21" selection-start-line="21" selection-end-line="22" selection-end-column="35" />
             </state>
           </provider>
         </entry>
@@ -238,7 +197,6 @@
   <component name="IdeDocumentHistory">
     <option name="CHANGED_PATHS">
       <list>
-        <option value="$PROJECT_DIR$/spiders/wangqiuls.py" />
         <option value="$PROJECT_DIR$/spiders/temaball.py" />
         <option value="$PROJECT_DIR$/spiders/wqguanjun.py" />
         <option value="$PROJECT_DIR$/spiders/lqguanjun.py" />
@@ -289,14 +247,15 @@
         <option value="$PROJECT_DIR$/spiders/zuqiu.py" />
         <option value="$PROJECT_DIR$/settings.py" />
         <option value="$PROJECT_DIR$/main.py" />
+        <option value="$PROJECT_DIR$/.gitignore" />
       </list>
     </option>
   </component>
   <component name="ProjectFrameBounds" extendedState="6">
-    <option name="x" value="262" />
-    <option name="y" value="79" />
-    <option name="width" value="1437" />
-    <option name="height" value="1029" />
+    <option name="x" value="617" />
+    <option name="y" value="94" />
+    <option name="width" value="1058" />
+    <option name="height" value="1066" />
   </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
   <component name="ProjectView">
@@ -304,6 +263,7 @@
       <foldersAlwaysOnTop value="true" />
     </navigator>
     <panes>
+      <pane id="Scope" />
       <pane id="ProjectPane">
         <subPane>
           <expand>
@@ -311,11 +271,6 @@
               <item name="hg3535" type="b2602c69:ProjectViewProjectNode" />
               <item name="hg3535" type="462c0819:PsiDirectoryNode" />
             </path>
-            <path>
-              <item name="hg3535" type="b2602c69:ProjectViewProjectNode" />
-              <item name="hg3535" type="462c0819:PsiDirectoryNode" />
-              <item name="spiders" type="462c0819:PsiDirectoryNode" />
-            </path>
             <path>
               <item name="hg3535" type="b2602c69:ProjectViewProjectNode" />
               <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
@@ -324,12 +279,11 @@
           <select />
         </subPane>
       </pane>
-      <pane id="Scope" />
     </panes>
   </component>
   <component name="PropertiesComponent">
     <property name="WebServerToolWindowFactoryState" value="false" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/../../../sports_scrapy/hg3535" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
     <property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
@@ -580,6 +534,7 @@
       <workItem from="1559817639837" duration="2439000" />
       <workItem from="1559820318166" duration="6091000" />
       <workItem from="1560128279184" duration="2486000" />
+      <workItem from="1564469892436" duration="268000" />
     </task>
     <task id="LOCAL-00001" summary="修改后,版本二">
       <created>1555727493584</created>
@@ -760,7 +715,7 @@
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="1582659000" />
+    <option name="totallyTimeSpent" value="1582927000" />
   </component>
   <component name="TodoView">
     <todo-panel id="selected-file">
@@ -774,7 +729,7 @@
   <component name="ToolWindowManager">
     <frame x="-8" y="-8" width="1936" height="1066" extended-state="6" />
     <layout>
-      <window_info content_ui="combo" id="Project" order="0" sideWeight="0.71173847" visible="true" weight="0.15458423" />
+      <window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.71173847" visible="true" weight="0.15618336" />
       <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" />
@@ -901,11 +856,6 @@
           <line>84</line>
           <option name="timeStamp" value="4" />
         </line-breakpoint>
-        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
-          <url>file://$PROJECT_DIR$/spiders/roll_wangqiu.py</url>
-          <line>232</line>
-          <option name="timeStamp" value="13" />
-        </line-breakpoint>
       </breakpoints>
       <default-breakpoints>
         <breakpoint type="python-exception">
@@ -933,34 +883,6 @@
     </expressions>
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/encodings/idna.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="223">
-          <caret line="167" selection-start-line="167" selection-end-line="167" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/w3lib/url.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="151">
-          <caret line="75" selection-start-line="75" selection-end-line="75" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/scrapy/core/downloader/middleware.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="159">
-          <caret line="65" selection-start-line="65" selection-end-line="65" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/scrapy/utils/trackref.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="159">
-          <caret line="30" selection-start-line="30" selection-end-line="30" />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/w3lib/util.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="184">
@@ -1117,16 +1039,6 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/ball_func.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="241">
-          <caret line="145" selection-start-line="145" selection-end-line="145" />
-          <folding>
-            <element signature="e#0#15#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$PROJECT_DIR$/spiders/roll_bangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="558">
@@ -1188,33 +1100,16 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/roll_zuqiu.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="7038">
-          <caret line="399" column="59" selection-start-line="399" selection-start-column="59" selection-end-line="399" selection-end-column="59" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/wangqiu.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="126">
-          <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$/spiders/lanqiu.py">
+    <entry file="file://$PROJECT_DIR$/settings.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="648">
-          <caret line="42" column="19" selection-start-line="42" selection-start-column="19" selection-end-line="42" selection-end-column="19" />
-          <folding>
-            <element signature="e#24#35#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="2736">
+          <caret line="152" column="20" selection-start-line="152" selection-start-column="20" selection-end-line="152" 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="18">
+        <state relative-caret-position="31158">
           <caret line="1742" column="34" selection-start-line="1742" selection-start-column="34" selection-end-line="1742" selection-end-column="34" />
           <folding>
             <element signature="e#0#11#0" expanded="true" />
@@ -1231,7 +1126,7 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/spiders/zq_jieshu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="90">
+        <state relative-caret-position="450">
           <caret line="30" column="20" selection-start-line="30" selection-start-column="20" selection-end-line="30" selection-end-column="20" />
           <folding>
             <element signature="e#36#51#0" expanded="true" />
@@ -1241,7 +1136,7 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/spiders/wq_jieshu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="630">
+        <state relative-caret-position="882">
           <caret line="54" column="94" selection-start-line="54" selection-start-column="94" selection-end-line="54" selection-end-column="94" />
           <folding>
             <element signature="e#24#39#0" expanded="true" />
@@ -1249,32 +1144,69 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/zuqiu.py">
+    <entry file="file://$PROJECT_DIR$/spiders/roll_zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="162">
-          <caret line="21" selection-start-line="21" selection-end-line="22" selection-end-column="103" />
-          <folding>
-            <element signature="e#24#35#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="7038">
+          <caret line="399" column="59" selection-start-line="399" selection-start-column="59" selection-end-line="399" selection-end-column="59" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/settings.py">
+    <entry file="file://$PROJECT_DIR$/spiders/wangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="216">
-          <caret line="152" column="22" lean-forward="true" selection-start-line="152" selection-start-column="22" selection-end-line="152" selection-end-column="22" />
+        <state relative-caret-position="126">
+          <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$/spiders/lanqiu.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="648">
+          <caret line="42" column="19" selection-start-line="42" selection-start-column="19" selection-end-line="42" selection-end-column="19" />
+          <folding>
+            <element signature="e#24#35#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/main.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="288">
-          <caret line="16" column="51" lean-forward="true" selection-start-line="16" selection-start-column="51" selection-end-line="16" selection-end-column="51" />
+          <caret line="16" column="51" selection-start-line="16" selection-start-column="51" selection-end-line="16" selection-end-column="51" />
           <folding>
             <element signature="e#0#10#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
+    <entry file="file://$PROJECT_DIR$/utils/helper.py">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/spiders/__init__.py">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/ball_func.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="133">
+          <caret line="145" selection-start-line="145" selection-end-line="145" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/spiders/zuqiu.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="-8370">
+          <caret line="21" selection-start-line="21" selection-end-line="22" selection-end-column="35" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/.gitignore">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="180">
+          <caret line="10" column="20" lean-forward="true" selection-start-line="10" selection-start-column="20" selection-end-line="10" selection-end-column="20" />
+        </state>
+      </provider>
+    </entry>
   </component>
 </project>

+ 2 - 2
hg3535/__init__.py

@@ -1,2 +1,2 @@
-import pymysql
-pymysql.install_as_MySQLdb()
+# import pymysql
+# pymysql.install_as_MySQLdb()

+ 398 - 940
hg3535/ball_func.py

@@ -2,6 +2,7 @@ import datetime
 import hashlib
 import time
 
+
 # 生成哈希索引 sole
 def hash_func(match_id, odds_code, sort, p_id):
     m = hashlib.md5()
@@ -49,350 +50,25 @@ def fuhao(f):
         return f
 
 
-# 篮球插入赔率 -----------------------------------------------------------------------------------------------------------
-def one_intodb(data1, data2, data3, cursor, redis_db):
-    if data1:
-        for key, value in data1.items():
-            if value:
-                for x, y in enumerate(value):
-                    new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=x, p_id=data2['p_id'])
-                    r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=x, p_id=data2['p_id'],odd=y)
-                    odds_only = r_hash
-                    l_f = fuhao(str(data3[key][x]))
-                    if redis_db.hexists("hg3535_lanqiu", r_hash):
-                        pass
-                    else:
-                        redis_db.hset("hg3535_lanqiu", r_hash, 0)
-                        sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-                        cursor.execute(sql1, (
-                            int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], y,
-                            data2['p_id'], data2["p_code"], x, data2["source"], new_hash,
-                            l_f, data2['expire_time'], odds_only,data2['utime'], y, data2['expire_time'],
-                            odds_only, l_f))
-                        # 更新主队st_zq_odds_record表
-                        sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s);"
-                        cursor.execute(sql2, (
-                            int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], y,
-                            data2['p_id'], data2["p_code"], x, data2["source"], l_f, odds_only))
-
-
-def two_intodb(data1, data2, data3, cursor, redis_db):
-    if data1:
-        for key, value in data1.items():
-            if value:
-                new_hash = hash_func(match_id=data2['game_id'], odds_code=data3 + key, sort=data2['sort'], p_id=data2['p_id'])
-
-                r_hash = r_func(match_id=data2['game_id'], odds_code=data3 + key, sort=data2['sort'], p_id=data2['p_id'],odd=value)
-                odds_only = r_hash
-                if redis_db.hexists("hg3535_lanqiu", r_hash):
-                    pass
-                else:
-                    redis_db.hset("hg3535_lanqiu", r_hash, 0)
-                    sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-                    cursor.execute(sql1, (
-                        int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-                        data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-                        key, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'], odds_only,key))
-                    # 更新主队st_zq_odds_record表
-                    sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s);"
-                    cursor.execute(sql2, (
-                        int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-                        data2['p_id'], data2["p_code"], data2['sort'], data2["source"], key, odds_only))
-
-
-def three_intodb(data1, data2, cursor, redis_db):
-    if data1:
-        for key, value in data1.items():
-            if value:
-                new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
-
-                r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'],odd=value)
-                odds_only = r_hash
-                if redis_db.hexists("hg3535_lanqiu", r_hash):
-                    pass
-                else:
-                    redis_db.hset("hg3535_lanqiu", r_hash, 0)
-                    sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s;"
-                    cursor.execute(sql1, (
-                        int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-                        data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash, data2['expire_time'],
-                        odds_only,data2['utime'], value, data2['expire_time'], odds_only))
-                    # 更新主队st_zq_odds_record表
-                    sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-                    cursor.execute(sql2, (
-                        int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-                        data2['p_id'], data2["p_code"], data2['sort'], data2["source"], odds_only))
-
-
-
-# 插入篮球赛事表
-def into_competition(data, cursor):
-    Competition_sql = "insert into st_lq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag, type, source,expire_time,is_today,is_morningplate,is_stringscene) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s,%s, %s, %s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s,is_morningplate=%s,is_stringscene=%s;"
-    cursor.execute(Competition_sql, (
-        data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
-        data['match_time'],
-        data['utime'], data['utime'], data['number'], data['pt'], data["source"], data['expire_time'], data['is_today'],
-        data['is_morningplate'], data['is_stringscene'], data['number'], data['expire_time'], data['is_today'],
-        data['is_morningplate'], data['is_stringscene']))
-
-
-# 插入足球赛事表----------------------------------------------------------------------------------------------------------
-def zqone_competition(data, cursor):
-    Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_today,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s,us_time=%s;"
-    cursor.execute(Competition_sql, (
-        data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
-        data['match_time'],
-        data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_today'],
-        data['us_time'], data['number'], data['expire_time'], data['is_today'],data['us_time']))
-
-
-def zqtwo_competition(data, cursor):
-    Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_morningplate,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_morningplate=%s,us_time=%s;"
-    cursor.execute(Competition_sql, (
-        data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
-        data['match_time'],
-        data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_morningplate'],
-        data['us_time'], data['number'], data['expire_time'], data['is_morningplate'], data['us_time']))
-
-
-def zqthree_competition(data, cursor):
-    Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_stringscene,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_stringscene=%s,us_time=%s;"
-    cursor.execute(Competition_sql, (
-        data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
-        data['match_time'],
-        data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_stringscene'],
-        data['us_time'], data['number'], data['expire_time'], data['is_stringscene'], data['us_time']))
-
-
-# 足球 插入赔率 让球 大小-------------------------------------------------------------------------------------------------
-def zqone_intodb(data1, data2, data3, data4, cursor, redis_db):
-    if data1:
-        for index, value in enumerate(data1):
-            if value:
-                new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'])
-                r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'], odd=value)
-                odds_only = r_hash
-                f1 = fuhao(str(data4[index]))
-                if redis_db.hexists("hg3535_zuqiu", r_hash):
-                    pass
-                else:
-                    redis_db.hset("hg3535_zuqiu", r_hash, 0)
-                    sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-                    cursor.execute(sql1, (
-                        int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-                        data2['p_id'], data2["p_code"], index, data2["source"], new_hash,
-                        f1, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'],
-                        odds_only, f1))
-
-                    # 更新主队st_zq_odds_record表
-                    sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-                    cursor.execute(sql2, (
-                        int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-                        data2['p_id'], data2["p_code"], index, data2["source"], f1, odds_only))
-
-
-
-# 足球 插入赔率  独赢 单双
-def zqtwo_intodb(data1, data2, data3, data4, cursor, redis_db):
-    if data1:
-        new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'])
-        r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'],
-                        odd=data1)
-        odds_only = r_hash
-        if redis_db.hexists("hg3535_zuqiu", r_hash):
-            pass
-        else:
-            redis_db.hset("hg3535_zuqiu", r_hash, 0)
-            sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time, odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-            cursor.execute(sql1, (
-                int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
-                data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-                data4, data2['expire_time'], odds_only, data2['utime'], data1, data2['expire_time'], odds_only,data4))
-            # 更新主队st_zq_odds_record表
-            sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s,%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-            cursor.execute(sql2, (
-                int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
-                data2['p_id'], data2["p_code"], data2['sort'], data2["source"], data4, odds_only))
-
-
-def gjz_into(data, cursor, r_hash, s_hash, redis_db):
-    if redis_db.hexists('hg3535_guanjun', r_hash):
-        pass
-    else:
-        redis_db.hset('hg3535_guanjun', r_hash, 0)
-        # if pt == 1:
-        sql = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
-        cursor.execute(sql, (
-            int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-            data['champion_team'], data['p_id'], data['new_league_name'],
-            data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
-            data['champion_team'], data['expire_time'], data['odds_only']))
-        # 插入st_zq_odds_record表
-        new_sql = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
-        cursor.execute(new_sql, (
-            int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-            data['champion_team'], data['p_id'], data['new_league_name'],
-            data['tema_home'], 1, "hg3535", data['odds_only']))
-
-    if redis_db.hexists('hg3535_liansai', s_hash):
-        pass
-    else:
-        redis_db.hset('hg3535_liansai', s_hash, 0)
-        league_sql = "insert into st_zq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
-        cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
-
-
-def gjl_into(data, cursor, r_hash, s_hash, redis_db):
-    if redis_db.hexists('hg3535_guanjun', r_hash):
-        pass
-    else:
-        redis_db.hset('hg3535_guanjun', r_hash, 0)
-        sql = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
-        cursor.execute(sql, (
-            int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-            data['champion_team'], data['p_id'], data['new_league_name'],
-            data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
-            data['champion_team'], data['expire_time'], data['odds_only']))
-        # 插入st_zq_odds_record表
-        new_sql = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
-        cursor.execute(new_sql, (
-            int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-            data['champion_team'], data['p_id'], data['new_league_name'],
-            data['tema_home'], 1, "hg3535", data['odds_only']))
-    # 插入st_zq_league表
-    if redis_db.hexists('hg3535_liansai', s_hash):
-        pass
-    else:
-        redis_db.hset('hg3535_liansai', s_hash, 0)
-        league_sql = "insert into st_lq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
-        cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
-
-
-def gjw_into(data, cursor, r_hash, s_hash, redis_db):
-    if redis_db.hexists('hg3535_guanjun', r_hash):
-        pass
-    else:
-        redis_db.hset('hg3535_guanjun', r_hash, 0)
-        sql = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
-        cursor.execute(sql, (
-            int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-            data['champion_team'], data['p_id'], data['new_league_name'],
-            data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
-            data['champion_team'], data['expire_time'], data['odds_only']))
-        # 插入st_zq_odds_record表
-        new_sql = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s,%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s)"
-        cursor.execute(new_sql, (
-            int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-            data['champion_team'], data['p_id'], data['new_league_name'],
-            data['tema_home'], 1, "hg3535", data['odds_only']))
-    # 插入st_zq_league表
-    if redis_db.hexists('hg3535_liansai', s_hash):
-        pass
-    else:
-        redis_db.hset('hg3535_liansai', s_hash, 0)
-        league_sql = "insert into st_wq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
-        cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
-
-
-def gjb_into(data, cursor, r_hash, s_hash, redis_db):
-    if redis_db.hexists('hg3535_guanjun', r_hash):
-        pass
-    else:
-        redis_db.hset('hg3535_guanjun', r_hash, 0)
-        sql = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
-        cursor.execute(sql, (
-            int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-            data['champion_team'], data['p_id'], data['new_league_name'],
-            data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
-            data['champion_team'], data['expire_time'], data['odds_only']))
-        # 插入st_zq_odds_record表
-        new_sql = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
-        cursor.execute(new_sql, (
-            int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-            data['champion_team'], data['p_id'], data['new_league_name'],
-            data['tema_home'], 1, "hg3535", data['odds_only']))
-    # 插入st_zq_league表
-    if redis_db.hexists('hg3535_liansai', s_hash):
-        pass
-    else:
-        redis_db.hset('hg3535_liansai', s_hash, 0)
-        league_sql = "insert into st_bq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
-        cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
-
-
-# 网球 插入赔率----------------------------------------------------------------------------------------------------------
-def wqone_intodb(data1, data2, data3, cursor, redis_db):
-    if data1:
-        for key, value in data1.items():
-            if value:
-                new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
-                r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'], odd=value)
-                odds_only = r_hash
-                w_f = fuhao(str(data3[key]))
-                if redis_db.hexists("hg3535_wangqiu", r_hash):
-                    pass
-                else:
-                    redis_db.hset("hg3535_wangqiu", r_hash, 0)
-                    sql1 = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-                    cursor.execute(sql1, (
-                        int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
-                        data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-                        w_f, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'],
-                        odds_only, w_f))
-                    # 更新主队st_zq_odds_record表
-                    sql2 = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-                    cursor.execute(sql2, (
-                        int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
-                        data2['p_id'], data2["p_code"], data2['sort'], data2["source"], w_f, odds_only))
-
-
-# 棒球 插入赔率----------------------------------------------------------------------------------------------------------
-def bqone_intodb(data1, data2, data3, cursor, redis_db):
-    if data1:
-        for key, value in data1.items():
-            if value:
-                new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
-                r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'], odd=value)
-                odds_only = r_hash
-                b_f = fuhao(str(data3[key]))
-                if redis_db.hexists("hg3535_bangqiu", r_hash):
-                    pass
-                else:
-                    redis_db.hset("hg3535_bangqiu", r_hash, 0)
-                    sql1 = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s"
-                    cursor.execute(sql1, (
-                        int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
-                        data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-                        b_f, data2['expire_time'], odds_only, data2['utime'], value,data2['expire_time'],
-                        odds_only, b_f))
-                    # 更新主队st_zq_odds_record表
-                    sql2 = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s, %s);"
-                    cursor.execute(sql2, (
-                        int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
-                        data2['p_id'], data2["p_code"], data2['sort'], data2["source"], b_f, odds_only))
-
-
-
 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 == "角球":
-        p_code = "corner_ball"
-        p_id = 9
-    elif corner_ball == "会晋级":
-        p_code = "promotion"
-        p_id = 10
-    elif corner_ball == "罚牌数":
-        # p_code = "Penalty_card"
-        p_code = "penalty_card"
-        p_id = 12
+    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:
-        p_code = code
-        p_id = code_dict[code]
-    return p_code, p_id
-
-
-
+        return code, code_dict[code]
 
 
 # ----------------------------------------------------------------------------------------------------------------------
@@ -406,102 +82,6 @@ def new_times(ctime):
     return match_date,match_time
 
 
-def zqone_intodbs(data1, data2, data3, data4, cursor, redis_db):
-    if data1:
-        for index, value in enumerate(data1):
-            if value:
-                new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'])
-                r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'], odd=value)
-                odds_only = r_hash
-                if redis_db.hexists("hg3535_zuqiu", r_hash):
-                    pass
-                else:
-                    redis_db.hset("hg3535_zuqiu", r_hash, 0)
-                    # if data2['pt'] == 0:
-                    sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only,is_rollball) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-                    cursor.execute(sql1, (
-                        int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-                        data2['p_id'], data2["p_code"], index, data2["source"], new_hash,
-                        data4[index], data2['expire_time'], odds_only, 1, data2['utime'], value, data2['expire_time'],
-                        odds_only,data4[index]))
-
-                    # 更新主队st_zq_odds_record表
-                    sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only,is_rollball) values (%s,%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-                    cursor.execute(sql2, (
-                        int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-                        data2['p_id'], data2["p_code"], index, data2["source"], data4[index], odds_only,1))
-                    #写入数据设置默认值竟然不生效 待看
-                    sql3 = "insert into st_zq_result(match_id, match_score, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_winer, update_time, match_time,match_process,tag,lg_id,u_home_score,u_guest_score,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set update_time=%s,match_score=%s,match_time=%s,match_process=%s,home_score=%s,guest_score=%s;"
-                    cursor.execute(sql3, (
-                        int(data2['game_id']), data2['match_score'],data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],0,1,'','','',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['league_id']),0,0,'hg3535',data2["p_code"],data2['utime'],data2['match_score'],data2['time_game'],data2['half_way'],data2['score_home'],data2['score_guest']
-                    ))
-
-                    sql4 = "insert into st_zq_result_record(lg_id, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_score, match_winer, update_time, match_time,match_process,tag,match_id,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s);"
-                    cursor.execute(sql4, (
-                        int(data2['league_id']), data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],0,1,'','',data2['match_score'],'',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['game_id']),'hg3535',data2["p_code"]
-                    ))
-
-
-def zqtwo_intodbs(data1, data2, data3, data4, cursor, redis_db):
-    if data1:
-        new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'])
-        r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'],
-                        odd=data1)
-        odds_only = r_hash
-        if redis_db.hexists("hg3535_zuqiu", r_hash):
-            pass
-        else:
-            redis_db.hset("hg3535_zuqiu", r_hash, 0)
-            # if data2['pt'] == 1:
-            sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time, odds_only,is_today) values (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-            cursor.execute(sql1, (
-                int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
-                data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-                data4, data2['expire_time'], odds_only, 1, data2['utime'], data1, data2['expire_time'], odds_only,data4))
-            # 更新主队st_zq_odds_record表
-            sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only, is_today) values (%s,%s,%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-            cursor.execute(sql2, (
-                int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
-                data2['p_id'], data2["p_code"], data2['sort'], data2["source"], data4, odds_only, 1))
-
-            sql3 = "insert into st_zq_result(match_id, match_score, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_winer, update_time, match_time,match_process,tag,lg_id,u_home_score,u_guest_score,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set update_time=%s,match_score=%s,match_time=%s,match_process=%s,home_score=%s,guest_score=%s;"
-            cursor.execute(sql3, (
-                    int(data2['game_id']), data2['match_score'],data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],0,1,'','','',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['league_id']),0,0,'hg3535',data2["p_code"],data2['utime'],data2['match_score'],data2['time_game'],data2['half_way'],data2['score_home'],data2['score_guest']
-                ))
-
-            sql4 = "insert into st_zq_result_record(lg_id, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_score, match_winer, update_time, match_time,match_process,tag,match_id,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s);"
-            cursor.execute(sql4, (
-                    int(data2['league_id']), data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],0,1,'','',data2['match_score'],'',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['game_id']),'hg3535',data2["p_code"]
-                ))
-
-
-def zqone_competitions(data, cursor):
-    Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, status, match_id, match_date, match_time, ctime, utime,tag, source,type,expire_time,us_time,is_rollball) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set utime = %s,status=%s,tag=%s,expire_time=%s;"
-    cursor.execute(Competition_sql, (
-        data['team_home'], data['team_guest'], data['league_id'],1,data['game_id'], data['match_date'],
-        data['match_time'],
-        data['utime'], data['utime'], data['number'], data["source"], 4,data['expire_time'], data['us_time'],data['is_rollball'],
-        data['utime'], 1, data['number'], data['expire_time']))
-
-
-def get_pcodes(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 == "角球":
-        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
-
-
 def news_times(ctime):
     time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
     time2 = time.localtime(time1)
@@ -513,508 +93,386 @@ def news_times(ctime):
     return match_date, match_time, time3
 
 
-# def hash_func(match_id, odds_code, sort, p_id):
-#     m = hashlib.md5()
-#     a = str(match_id) + str(odds_code) + str(sort) + str(p_id)
-#     m.update(a.encode('utf-8'))
-#     c = m.hexdigest()
-#     return c
-#
-#
-# # 生成odds_only哈希
-# def r_func(match_id, odds_code, sort, p_id, odd):
-#     m = hashlib.md5()
-#     a = str(match_id) + str(odds_code) + str(sort) + str(p_id) + str(odd)
-#     m.update(a.encode('utf-8'))
-#     c = m.hexdigest()
-#     return c
-#
-#
-# # 转换成本地时间
-# def new_time(ctime):
-#     time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
-#     time2 = time.localtime(time1)
-#     time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
-#     time4 = time3
-#     data_time = str(time4).split(" ")
-#     match_date = data_time[0]
-#     match_time = data_time[1]
-#     return match_date, match_time, time3
-#
-#
-# def out_time(ctime, i):
-#     ctime1 = datetime.datetime.strptime(ctime, "%Y-%m-%d %H:%M:%S")
-#     n_ctime = (ctime1 + datetime.timedelta(hours=i)).strftime("%Y-%m-%d %H:%M:%S")
-#     return n_ctime
-#
-#
-# def fuhao(f):
-#     if f.startswith('+'):
-#         f = f.replace('+', '-')
-#         return f
-#     elif f.startswith('-'):
-#         f = f.replace('-', '+')
-#         return f
-#     else:
-#         return f
-#
-#
-# # 篮球插入赔率 -----------------------------------------------------------------------------------------------------------
-# def one_intodb(data1, data2, data3, cursor, redis_db):
-#     if data1:
-#         for key, value in data1.items():
-#             if value:
-#                 for x, y in enumerate(value):
-#                     new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=x, p_id=data2['p_id'])
-#                     r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=x, p_id=data2['p_id'],odd=y)
-#                     odds_only = r_hash
-#                     l_f = fuhao(str(data3[key][x]))
-#                     if redis_db.hexists("hg3535_lanqiu", r_hash):
-#                         pass
-#                     else:
-#                         redis_db.hset("hg3535_lanqiu", r_hash, 0)
-#                         sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-#                         cursor.execute(sql1, (
-#                             int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], y,
-#                             data2['p_id'], data2["p_code"], x, data2["source"], new_hash,
-#                             l_f, data2['expire_time'], odds_only,data2['utime'], y, data2['expire_time'],
-#                             odds_only, l_f))
-#                         # 更新主队st_zq_odds_record表
-#                         sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s);"
-#                         cursor.execute(sql2, (
-#                             int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], y,
-#                             data2['p_id'], data2["p_code"], x, data2["source"], l_f, odds_only))
-#
-#
-# def two_intodb(data1, data2, data3, cursor, redis_db):
-#     if data1:
-#         for key, value in data1.items():
-#             if value:
-#                 new_hash = hash_func(match_id=data2['game_id'], odds_code=data3 + key, sort=data2['sort'], p_id=data2['p_id'])
-#
-#                 r_hash = r_func(match_id=data2['game_id'], odds_code=data3 + key, sort=data2['sort'], p_id=data2['p_id'],odd=value)
-#                 odds_only = r_hash
-#                 if redis_db.hexists("hg3535_lanqiu", r_hash):
-#                     pass
-#                 else:
-#                     redis_db.hset("hg3535_lanqiu", r_hash, 0)
-#                     sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-#                     cursor.execute(sql1, (
-#                         int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-#                         data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-#                         key, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'], odds_only,key))
-#                     # 更新主队st_zq_odds_record表
-#                     sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s);"
-#                     cursor.execute(sql2, (
-#                         int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-#                         data2['p_id'], data2["p_code"], data2['sort'], data2["source"], key, odds_only))
-#
-#
-# def three_intodb(data1, data2, cursor, redis_db):
-#     if data1:
-#         for key, value in data1.items():
-#             if value:
-#                 new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
-#
-#                 r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'],odd=value)
-#                 odds_only = r_hash
-#                 if redis_db.hexists("hg3535_lanqiu", r_hash):
-#                     pass
-#                 else:
-#                     redis_db.hset("hg3535_lanqiu", r_hash, 0)
-#                     sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s;"
-#                     cursor.execute(sql1, (
-#                         int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-#                         data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash, data2['expire_time'],
-#                         odds_only,data2['utime'], value, data2['expire_time'], odds_only))
-#                     # 更新主队st_zq_odds_record表
-#                     sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-#                     cursor.execute(sql2, (
-#                         int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-#                         data2['p_id'], data2["p_code"], data2['sort'], data2["source"], odds_only))
-#
-#
-# # 插入篮球赛事表
-# def into_competition(data, cursor):
-#     Competition_sql = "insert into st_lq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag, type, source,expire_time,is_today,is_morningplate,is_stringscene) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s,%s, %s, %s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s,is_morningplate=%s,is_stringscene=%s;"
-#     cursor.execute(Competition_sql, (
-#         data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
-#         data['match_time'],
-#         data['utime'], data['utime'], data['number'], data['pt'], data["source"], data['expire_time'], data['is_today'],
-#         data['is_morningplate'], data['is_stringscene'], data['number'], data['expire_time'], data['is_today'],
-#         data['is_morningplate'], data['is_stringscene']))
-#
-#
-# # 插入足球赛事表----------------------------------------------------------------------------------------------------------
-# def zqone_competition(data, cursor):
-#     Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_today,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s,us_time=%s;"
-#     cursor.execute(Competition_sql, (
-#         data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
-#         data['match_time'],
-#         data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_today'],
-#         data['us_time'], data['number'], data['expire_time'], data['is_today'],data['us_time']))
-#
-#
-# def zqtwo_competition(data, cursor):
-#     Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_morningplate,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_morningplate=%s,us_time=%s;"
-#     cursor.execute(Competition_sql, (
-#         data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
-#         data['match_time'],
-#         data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_morningplate'],
-#         data['us_time'], data['number'], data['expire_time'], data['is_morningplate'], data['us_time']))
-#
-#
-# def zqthree_competition(data, cursor):
-#     Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_stringscene,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_stringscene=%s,us_time=%s;"
-#     cursor.execute(Competition_sql, (
-#         data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
-#         data['match_time'],
-#         data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_stringscene'],
-#         data['us_time'], data['number'], data['expire_time'], data['is_stringscene'], data['us_time']))
-#
-#
-# # 足球 插入赔率 让球 大小-------------------------------------------------------------------------------------------------
-# def zqone_intodb(data1, data2, data3, data4, cursor, redis_db):
-#     if data1:
-#         for index, value in enumerate(data1):
-#             if value:
-#                 new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'])
-#                 r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'], odd=value)
-#                 odds_only = r_hash
-#                 f1 = fuhao(str(data4[index]))
-#                 if redis_db.hexists("hg3535_zuqiu", r_hash):
-#                     pass
-#                 else:
-#                     redis_db.hset("hg3535_zuqiu", r_hash, 0)
-#                     sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-#                     cursor.execute(sql1, (
-#                         int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-#                         data2['p_id'], data2["p_code"], index, data2["source"], new_hash,
-#                         f1, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'],
-#                         odds_only, f1))
-#
-#                     # 更新主队st_zq_odds_record表
-#                     sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-#                     cursor.execute(sql2, (
-#                         int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-#                         data2['p_id'], data2["p_code"], index, data2["source"], f1, odds_only))
-#
-#
-#
-# # 足球 插入赔率  独赢 单双
-# def zqtwo_intodb(data1, data2, data3, data4, cursor, redis_db):
-#     if data1:
-#         new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'])
-#         r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'],
-#                         odd=data1)
-#         odds_only = r_hash
-#         if redis_db.hexists("hg3535_zuqiu", r_hash):
-#             pass
-#         else:
-#             redis_db.hset("hg3535_zuqiu", r_hash, 0)
-#             sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time, odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-#             cursor.execute(sql1, (
-#                 int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
-#                 data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-#                 data4, data2['expire_time'], odds_only, data2['utime'], data1, data2['expire_time'], odds_only,data4))
-#             # 更新主队st_zq_odds_record表
-#             sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s,%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-#             cursor.execute(sql2, (
-#                 int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
-#                 data2['p_id'], data2["p_code"], data2['sort'], data2["source"], data4, odds_only))
-#
-#
-# def gjz_into(data, cursor, r_hash, s_hash, redis_db):
-#     if redis_db.hexists('hg3535_guanjun', r_hash):
-#         pass
-#     else:
-#         redis_db.hset('hg3535_guanjun', r_hash, 0)
-#         # if pt == 1:
-#         sql = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
-#         cursor.execute(sql, (
-#             int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-#             data['champion_team'], data['p_id'], data['new_league_name'],
-#             data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
-#             data['champion_team'], data['expire_time'], data['odds_only']))
-#         # 插入st_zq_odds_record表
-#         new_sql = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
-#         cursor.execute(new_sql, (
-#             int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-#             data['champion_team'], data['p_id'], data['new_league_name'],
-#             data['tema_home'], 1, "hg3535", data['odds_only']))
-#
-#     if redis_db.hexists('hg3535_liansai', s_hash):
-#         pass
-#     else:
-#         redis_db.hset('hg3535_liansai', s_hash, 0)
-#         league_sql = "insert into st_zq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
-#         cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
-#
-#
-# def gjl_into(data, cursor, r_hash, s_hash, redis_db):
-#     if redis_db.hexists('hg3535_guanjun', r_hash):
-#         pass
-#     else:
-#         redis_db.hset('hg3535_guanjun', r_hash, 0)
-#         sql = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
-#         cursor.execute(sql, (
-#             int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-#             data['champion_team'], data['p_id'], data['new_league_name'],
-#             data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
-#             data['champion_team'], data['expire_time'], data['odds_only']))
-#         # 插入st_zq_odds_record表
-#         new_sql = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
-#         cursor.execute(new_sql, (
-#             int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-#             data['champion_team'], data['p_id'], data['new_league_name'],
-#             data['tema_home'], 1, "hg3535", data['odds_only']))
-#     # 插入st_zq_league表
-#     if redis_db.hexists('hg3535_liansai', s_hash):
-#         pass
-#     else:
-#         redis_db.hset('hg3535_liansai', s_hash, 0)
-#         league_sql = "insert into st_lq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
-#         cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
-#
-#
-# def gjw_into(data, cursor, r_hash, s_hash, redis_db):
-#     if redis_db.hexists('hg3535_guanjun', r_hash):
-#         pass
-#     else:
-#         redis_db.hset('hg3535_guanjun', r_hash, 0)
-#         sql = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
-#         cursor.execute(sql, (
-#             int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-#             data['champion_team'], data['p_id'], data['new_league_name'],
-#             data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
-#             data['champion_team'], data['expire_time'], data['odds_only']))
-#         # 插入st_zq_odds_record表
-#         new_sql = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s,%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s)"
-#         cursor.execute(new_sql, (
-#             int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-#             data['champion_team'], data['p_id'], data['new_league_name'],
-#             data['tema_home'], 1, "hg3535", data['odds_only']))
-#     # 插入st_zq_league表
-#     if redis_db.hexists('hg3535_liansai', s_hash):
-#         pass
-#     else:
-#         redis_db.hset('hg3535_liansai', s_hash, 0)
-#         league_sql = "insert into st_wq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
-#         cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
-#
-#
-# def gjb_into(data, cursor, r_hash, s_hash, redis_db):
-#     if redis_db.hexists('hg3535_guanjun', r_hash):
-#         pass
-#     else:
-#         redis_db.hset('hg3535_guanjun', r_hash, 0)
-#         sql = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
-#         cursor.execute(sql, (
-#             int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-#             data['champion_team'], data['p_id'], data['new_league_name'],
-#             data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
-#             data['champion_team'], data['expire_time'], data['odds_only']))
-#         # 插入st_zq_odds_record表
-#         new_sql = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
-#         cursor.execute(new_sql, (
-#             int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
-#             data['champion_team'], data['p_id'], data['new_league_name'],
-#             data['tema_home'], 1, "hg3535", data['odds_only']))
-#     # 插入st_zq_league表
-#     if redis_db.hexists('hg3535_liansai', s_hash):
-#         pass
-#     else:
-#         redis_db.hset('hg3535_liansai', s_hash, 0)
-#         league_sql = "insert into st_bq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
-#         cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
-#
-#
-# # 网球 插入赔率----------------------------------------------------------------------------------------------------------
-# def wqone_intodb(data1, data2, data3, cursor, redis_db):
-#     if data1:
-#         for key, value in data1.items():
-#             if value:
-#                 new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
-#                 r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'], odd=value)
-#                 odds_only = r_hash
-#                 w_f = fuhao(str(data3[key]))
-#                 if redis_db.hexists("hg3535_wangqiu", r_hash):
-#                     pass
-#                 else:
-#                     redis_db.hset("hg3535_wangqiu", r_hash, 0)
-#                     sql1 = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-#                     cursor.execute(sql1, (
-#                         int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
-#                         data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-#                         w_f, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'],
-#                         odds_only, w_f))
-#                     # 更新主队st_zq_odds_record表
-#                     sql2 = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-#                     cursor.execute(sql2, (
-#                         int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
-#                         data2['p_id'], data2["p_code"], data2['sort'], data2["source"], w_f, odds_only))
-#
-#
-# # 棒球 插入赔率----------------------------------------------------------------------------------------------------------
-# def bqone_intodb(data1, data2, data3, cursor, redis_db):
-#     if data1:
-#         for key, value in data1.items():
-#             if value:
-#                 new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
-#                 r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'], odd=value)
-#                 odds_only = r_hash
-#                 b_f = fuhao(str(data3[key]))
-#                 if redis_db.hexists("hg3535_bangqiu", r_hash):
-#                     pass
-#                 else:
-#                     redis_db.hset("hg3535_bangqiu", r_hash, 0)
-#                     sql1 = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s"
-#                     cursor.execute(sql1, (
-#                         int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
-#                         data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-#                         b_f, data2['expire_time'], odds_only, data2['utime'], value,data2['expire_time'],
-#                         odds_only, b_f))
-#                     # 更新主队st_zq_odds_record表
-#                     sql2 = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s, %s);"
-#                     cursor.execute(sql2, (
-#                         int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
-#                         data2['p_id'], data2["p_code"], data2['sort'], data2["source"], b_f, odds_only))
-#
-#
-#
-# def get_pcode(corner_ball, code):
-#     code_dict = {'concede_size': 1, 'capot': 2, 'two_sides': 3, 'total_goal': 4, 'half_full': 5, 'bodan': 6,
-#                  'first_last_ball': 7, 'temaball': 11}
-#     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
-
-
-
-
-
-#滚球方法都加了s
-
-# def zqone_intodbs(data1, data2, data3, data4, cursor, redis_db):
-#     if data1:
-#         for index, value in enumerate(data1):
-#             if value:
-#                 new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'])
-#                 r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'], odd=value)
-#                 odds_only = r_hash
-#                 if redis_db.hexists("hg3535_zuqiu", r_hash):
-#                     pass
-#                 else:
-#                     redis_db.hset("hg3535_zuqiu", r_hash, 0)
-#                     # if data2['pt'] == 0:
-#                     sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only,is_rollball) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-#                     cursor.execute(sql1, (
-#                         int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-#                         data2['p_id'], data2["p_code"], index, data2["source"], new_hash,
-#                         data4[index], data2['expire_time'], odds_only, 1, data2['utime'], value, data2['expire_time'],
-#                         odds_only,data4[index]))
-#
-#                     # 更新主队st_zq_odds_record表
-#                     sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only,is_rollball) values (%s,%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-#                     cursor.execute(sql2, (
-#                         int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
-#                         data2['p_id'], data2["p_code"], index, data2["source"], data4[index], odds_only,1))
-#                     #写入数据设置默认值竟然不生效 待看
-#                     sql3 = "insert into st_zq_result(match_id, match_score, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_winer, update_time, match_time,match_process,tag,lg_id,u_home_score,u_guest_score,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set update_time=%s,match_score=%s,match_time=%s,match_process=%s,home_score=%s,guest_score=%s;"
-#                     cursor.execute(sql3, (
-#                         int(data2['game_id']), data2['match_score'],data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','','',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['league_id']),0,0,'hg3535',data2["p_code"],data2['utime'],data2['match_score'],data2['time_game'],data2['half_way'],data2['score_home'],data2['score_guest']
-#                     ))
-#
-#                     sql4 = "insert into st_zq_result_record(lg_id, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_score, match_winer, update_time, match_time,match_process,tag,match_id,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s);"
-#                     cursor.execute(sql4, (
-#                         int(data2['league_id']), data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','',data2['match_score'],'',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['game_id']),'hg3535',data2["p_code"]
-#                     ))
-#
-# def zqtwo_intodbs(data1, data2, data3, data4, cursor, redis_db):
-#     if data1:
-#         new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'])
-#         r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'],
-#                         odd=data1)
-#         odds_only = r_hash
-#         if redis_db.hexists("hg3535_zuqiu", r_hash):
-#             pass
-#         else:
-#             redis_db.hset("hg3535_zuqiu", r_hash, 0)
-#             # if data2['pt'] == 1:
-#             sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time, odds_only,is_today) values (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
-#             cursor.execute(sql1, (
-#                 int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
-#                 data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
-#                 data4, data2['expire_time'], odds_only, 1, data2['utime'], data1, data2['expire_time'], odds_only,data4))
-#             # 更新主队st_zq_odds_record表
-#             sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only, is_today) values (%s,%s,%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
-#             cursor.execute(sql2, (
-#                 int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
-#                 data2['p_id'], data2["p_code"], data2['sort'], data2["source"], data4, odds_only, 1))
-#
-#             sql3 = "insert into st_zq_result(match_id, match_score, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_winer, update_time, match_time,match_process,tag,lg_id,u_home_score,u_guest_score,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set update_time=%s,match_score=%s,match_time=%s,match_process=%s,home_score=%s,guest_score=%s;"
-#             cursor.execute(sql3, (
-#                     int(data2['game_id']), data2['match_score'],data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','','',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['league_id']),0,0,'hg3535',data2["p_code"],data2['utime'],data2['match_score'],data2['time_game'],data2['half_way'],data2['score_home'],data2['score_guest']
-#                 ))
-#
-#             sql4 = "insert into st_zq_result_record(lg_id, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_score, match_winer, update_time, match_time,match_process,tag,match_id,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s);"
-#             cursor.execute(sql4, (
-#                     int(data2['league_id']), data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','',data2['match_score'],'',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['game_id']),'hg3535',data2["p_code"]
-#                 ))
-#
-#
-# def zqone_competitions(data, cursor):
-#     Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, status, match_id, match_date, match_time, ctime, utime,tag, source,type,expire_time,us_time,is_rollball) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set utime = %s,status=%s,tag=%s,expire_time=%s;"
-#     cursor.execute(Competition_sql, (
-#         data['team_home'], data['team_guest'], data['league_id'],1,data['game_id'], data['match_date'],
-#         data['match_time'],
-#         data['utime'], data['utime'], data['number'], data["source"], 4,data['expire_time'], data['us_time'],data['is_rollball'],
-#         data['utime'], 1, data['number'], data['expire_time']))
-#
-#
-# def get_pcodes(corner_ball, code):
-#     code_dict = {'concede_size': 1, 'capot': 2, 'two_sides': 3, 'total_goal': 4, 'half_full': 5, 'bodan': 6,
-#                  'first_last_ball': 7, 'temaball': 11}
-#     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
-#
-#
-# def news_times(ctime):
-#     time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
-#     time2 = time.localtime(time1)
-#     time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
-#     time4 = time3
-#     data_time = str(time4).split(" ")
-#     match_date = data_time[0]
-#     match_time = data_time[1]
-#     return match_date, match_time, time3
+def one_post(data, match_id, odds_code, p_id, league_id, p_code, condition, game_code, zq_odds):
+    if data:
+        new_hash = hash_func(match_id=match_id, odds_code=odds_code, sort=0, p_id=p_id)
+        r_hash = r_func(match_id=match_id, odds_code=odds_code, sort=0, p_id=p_id, odd=data)
+        payload = {
+            "game_code": game_code,
+            "title": "odds",
+            "data": {
+                "match_id": match_id,
+                "lg_id": league_id,
+                "odds_code": odds_code,
+                "status": 0,
+                "sort": 0,
+                "p_code": p_code,
+                "odds": data,
+                "condition": condition,
+                "odds_only": r_hash,
+                "sole": new_hash,
+                "source": "hg3535",
+                "type": 0,
+                "team": ""
+            }
+        }
+        zq_odds.append(payload)
+        # return payload
+
+
+def two_post(data, match_id, odds_code, p_id, league_id, p_code, condition, game_code, zq_odds):
+    if data:
+        # odds_list = []
+        for index, value in enumerate(data):
+            if value:
+                s_hash = hash_func(match_id=match_id, odds_code=odds_code, sort=index, p_id=p_id)
+                o_hash = r_func(match_id=match_id, odds_code=odds_code, sort=index, p_id=p_id, odd=value)
+                f1 = fuhao(str(condition[index]))
+                payload = {
+                    "game_code": game_code,
+                    "title": "odds",
+                    "data": {
+                        "match_id": match_id,
+                        "lg_id": league_id,
+                        "odds_code": odds_code,
+                        "status": 0,
+                        "sort": index,
+                        "p_code": p_code,
+                        "odds": value,
+                        "condition": f1,
+                        "odds_only": o_hash,
+                        "sole": s_hash,
+                        "source": "hg3535",
+                        "type": 0,
+                        "team": ""
+                    }
+                }
+                zq_odds.append(payload)
+        #         odds_list.append(payload)
+        # return odds_list
+
+
+def three_post(data, match_id, p_id, league_id, p_code, condition, game_code, zq_odds):
+    if data:
+        # odd_list = []
+        for key, value in data.items():
+            if value:
+                s_hash = hash_func(match_id=match_id, odds_code=key, sort=0, p_id=p_id)
+                o_hash = r_func(match_id=match_id, odds_code=key, sort=0, p_id=p_id, odd=value)
+                try:
+                    f1 = fuhao(str(condition[key]))
+                except:
+                    f1 = ""
+                payload = {
+                    "game_code": game_code,
+                    "title": "odds",
+                    "data": {
+                        "match_id": match_id,
+                        "lg_id": league_id,
+                        "odds_code": key,
+                        "status": 0,
+                        "sort": 0,
+                        "p_code": p_code,
+                        "odds": value,
+                        "condition": f1,
+                        "odds_only": o_hash,
+                        "sole": s_hash,
+                        "source": "hg3535",
+                        "type": 0,
+                        "team": ""
+                    }
+                }
+                zq_odds.append(payload)
+        #         odd_list.append(payload)
+        # return odd_list
+
+
+def gs_post(ball, league_id, league_name, data_game):
+    if ball == "足球":
+        n_gameid = int('1' + str(league_id))
+        payload = {
+            "game_code": "zq",
+            "title": "competition",
+            "data": {
+                "home_team": league_name,
+                "guest_team": "",
+                "lg_id": league_id,
+                "status": 0,
+                "match_id": n_gameid,
+                "source": "hg3535",
+                "us_time": data_game,
+                "match_date": "",
+                "match_time": "",
+                "tag": "",
+                "is_rollball": 0,
+                "is_today": 0,
+                "is_morningplate": 0,
+                "is_stringscene": 0,
+                }
+        }
+    elif ball == "篮球":
+        n_gameid = int('1' + str(league_id))
+        payload = {
+            "game_code": "zq",
+            "title": "competition",
+            "data": {
+                "home_team": league_name,
+                "guest_team": "",
+                "lg_id": league_id,
+                "status": 0,
+                "match_id": n_gameid,
+                "source": "hg3535",
+                "us_time": data_game,
+                "match_date": "",
+                "match_time": "",
+                "tag": "",
+                "is_rollball": 0,
+                "is_today": 0,
+                "is_morningplate": 0,
+                "is_stringscene": 0,
+            }
+        }
+    elif ball == "网球":
+        n_gameid = int('1' + str(league_id))
+        payload = {
+            "game_code": "zq",
+            "title": "competition",
+            "data": {
+                "home_team": league_name,
+                "guest_team": "",
+                "lg_id": league_id,
+                "status": 0,
+                "match_id": n_gameid,
+                "source": "hg3535",
+                "us_time": data_game,
+                "match_date": "",
+                "match_time": "",
+                "tag": "",
+                "is_rollball": 0,
+                "is_today": 0,
+                "is_morningplate": 0,
+                "is_stringscene": 0,
+            }
+        }
+    elif ball == "棒球":
+        n_gameid = int('1' + str(league_id))
+        payload = {
+            "game_code": "zq",
+            "title": "competition",
+            "data": {
+                "home_team": league_name,
+                "guest_team": "",
+                "lg_id": league_id,
+                "status": 0,
+                "match_id": n_gameid,
+                "source": "hg3535",
+                "us_time": data_game,
+                "match_date": "",
+                "match_time": "",
+                "tag": "",
+                "is_rollball": 0,
+                "is_today": 0,
+                "is_morningplate": 0,
+                "is_stringscene": 0,
+            }
+        }
+    return payload
+
+
+def go_post(ball, league_id, new_champion, new_league_name, value, r_hash, new_hash, tema_home):
+    game_id = int('1' + str(league_id))
+    if ball == "足球":
+        payload = {
+            "game_code": "zq",
+            "title": "odds",
+            "data": {
+                "match_id": league_id,
+                "lg_id": game_id,
+                "odds_code": new_champion,
+                "status": 0,
+                "sort": 0,
+                "p_code": new_league_name,
+                "odds": value,
+                "condition": "",
+                "odds_only": r_hash,
+                "sole": new_hash,
+                "source": 'hg3535',
+                "type": 1,
+                "team": tema_home
+            }
+        }
+    elif ball == "篮球":
+        payload = {
+            "game_code": "lq",
+            "title": "odds",
+            "data": {
+                "match_id": league_id,
+                "lg_id": game_id,
+                "odds_code": new_champion,
+                "status": 0,
+                "sort": 0,
+                "p_code": new_league_name,
+                "odds": value,
+                "condition": "",
+                "odds_only": r_hash,
+                "sole": new_hash,
+                "source": "hg3535",
+                "type": 1,
+                "team": tema_home
+            }
+        }
+    elif ball == "网球":
+        payload = {
+            "game_code": "wq",
+            "title": "odds",
+            "data": {
+                "match_id": league_id,
+                "lg_id": game_id,
+                "odds_code": new_champion,
+                "status": 0,
+                "sort": 0,
+                "p_code": new_league_name,
+                "odds": value,
+                "condition": "",
+                "odds_only": r_hash,
+                "sole": new_hash,
+                "source": "hg3535",
+                "type": 1,
+                "team": tema_home
+            }
+        }
+    elif ball == "棒球":
+        payload = {
+            "game_code": "bq",
+            "title": "odds",
+            "data": {
+                "match_id": league_id,
+                "lg_id": game_id,
+                "odds_code": new_champion,
+                "status": 0,
+                "sort": 0,
+                "p_code": new_league_name,
+                "odds": value,
+                "condition": "",
+                "odds_only": r_hash,
+                "sole": new_hash,
+                "source": "hg3535",
+                "type": 1,
+                "team": tema_home
+            }
+        }
+    return payload
+
+
+def guanl_post(ball, league_name, league_id, time3):
+    if ball == "足球":
+        payload = {
+            "game_code": "zq",
+            "title": "league",
+            "data": {
+                "name_chinese": league_name,
+                "kind": "1",
+                "match_mode": "1",
+                "if_stop": "0",
+                # "belong": "",
+                "last_time": time3,
+                "lg_id": league_id,
+                "source": "hg3535"
+                }
+            }
+    elif ball == "篮球":
+        payload = {
+            "game_code": "zq",
+            "title": "league",
+            "data": {
+                "name_chinese": league_name,
+                "kind": "1",
+                "match_mode": "1",
+                "if_stop": "0",
+                # "belong": "",
+                "last_time": time3,
+                "lg_id": league_id,
+                "source": "hg3535"
+            }
+        }
+    elif ball == "网球":
+        payload = {
+            "game_code": "zq",
+            "title": "league",
+            "data": {
+                "name_chinese": league_name,
+                "kind": "1",
+                "match_mode": "1",
+                "if_stop": "0",
+                # "belong": "",
+                "last_time": time3,
+                "lg_id": league_id,
+                "source": "hg3535"
+            }
+        }
+    elif ball == "棒球":
+        payload = {
+            "game_code": "zq",
+            "title": "league",
+            "data": {
+                "name_chinese": league_name,
+                "kind": "1",
+                "match_mode": "1",
+                "if_stop": "0",
+                # "belong": "",
+                "last_time": time3,
+                "lg_id": league_id,
+                "source": "hg3535"
+            }
+        }
+    return payload
+
+
+def liansai(area_name, name_chinese, st_league, area_dict, game_code, qiu):
+    if area_name in area_dict:
+        payload = {
+            "game_code": game_code,
+            "title": "league",
+            "data": {
+                "name_chinese": name_chinese,
+                "kind": "1",
+                "match_mode": "1",
+                "if_stop": "0",
+                "belong": area_name,
+                "last_time": '2019-12-31 23:59:59',
+                "lg_id": st_league,
+                "source": "hg3535"
+            }
+        }
+    else:
+        if area_name == qiu:
+            payload = {
+                "game_code": game_code,
+                "title": "league",
+                "data": {
+                    "name_chinese": name_chinese,
+                    "kind": "1",
+                    "match_mode": "1",
+                    "if_stop": "0",
+                    "belong": " ",
+                    "last_time": '2019-12-31 23:59:59',
+                    "lg_id": st_league,
+                    "source": "hg3535"
+                }
+            }
+        else:
+            payload = {
+                "game_code": game_code,
+                "title": "league",
+                "data": {
+                    "name_chinese": name_chinese,
+                    "kind": "1",
+                    "match_mode": "1",
+                    "if_stop": "0",
+                    "belong": area_name,
+                    "last_time": '2019-12-31 23:59:59',
+                    "lg_id": st_league,
+                    "source": "hg3535"
+                }}
+    return payload
 
-# def new_times(ctime):
-#     time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
-#     time2 = time.localtime(time1)
-#     time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
-#     data_time = str(time3).split(" ")
-#     match_date = data_time[0]
-#     match_time = data_time[1]
-#     return match_date,match_time

+ 6 - 33
hg3535/items.py

@@ -63,18 +63,18 @@ class Liansai(scrapy.Field):
 # 冠军--------------------------------------------------------------------------------------------------------------
 class Guanjun(scrapy.Field):
     league_name = scrapy.Field()
-    tema_home = scrapy.Field()
+    # tema_home = scrapy.Field()
     league_id = scrapy.Field()
     game_id = scrapy.Field()
     data_game = scrapy.Field()
-    time_game = scrapy.Field()
+    # time_game = scrapy.Field()
     new_league_name = scrapy.Field()
-    champion_team = scrapy.Field()
+    # champion_team = scrapy.Field()
     new_champion = scrapy.Field()
     pt = scrapy.Field()
     ball = scrapy.Field()
-    zhuangtai = scrapy.Field()
-    champion = scrapy.Field()
+    # zhuangtai = scrapy.Field()
+    # champion = scrapy.Field()
 
 
 # 足球 --------------------------------------------------------------------------------------------------------------
@@ -327,7 +327,6 @@ class Zuqiustatus(scrapy.Field):
     zuqiu_toal = scrapy.Field()
 
 
-	
 class Roll_Lanqiu(scrapy.Field):
     # 联赛id
     league_id = scrapy.Field()
@@ -408,6 +407,7 @@ class Roll_Wangqiu(scrapy.Field):
     total_number_dict_rule = scrapy.Field()
     odd_evens_dict = scrapy.Field()
     odd_evens_dict_rule = scrapy.Field()
+    sq_dict = scrapy.Field()
 
 
 class Roll_Bangqiu(scrapy.Field):
@@ -449,33 +449,6 @@ class Roll_Bangqiu(scrapy.Field):
     match_score_dict = scrapy.Field()
 
 
-
-class Lanqiustatus(scrapy.Field):
-    match_id = scrapy.Field()
-    create_time = scrapy.Field()
-    status = scrapy.Field()
-    update_time = scrapy.Field()
-    ball_type = scrapy.Field()
-    zuqiu_toal = scrapy.Field()
-
-class Wanqiustatus(scrapy.Field):
-    match_id = scrapy.Field()
-    create_time = scrapy.Field()
-    status = scrapy.Field()
-    update_time = scrapy.Field()
-    ball_type = scrapy.Field()
-    zuqiu_toal = scrapy.Field()
-
-
-class Bangqiustatus(scrapy.Field):
-    match_id = scrapy.Field()
-    create_time = scrapy.Field()
-    status = scrapy.Field()
-    update_time = scrapy.Field()
-    ball_type = scrapy.Field()
-    zuqiu_toal = scrapy.Field()
-
-
 # -----------------------------------------------------------足球比赛结果------------------------------------------------
 class Zujieguo(scrapy.Field):
     # 足球比赛结果元组

+ 3 - 3
hg3535/main.py

@@ -7,12 +7,12 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
 # execute(["scrapy", "crawl", "liansai"])
 # execute(["scrapy", "crawl", "zuqiu"])
 # execute(["scrapy", "crawl", "lanqiu"])
-# execute(["scrapy", "crawl", "guanjun"])
+execute(["scrapy", "crawl", "guanjun"])
 # execute(["scrapy", "crawl", "wangqiu"])
 # 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", "ball_status"]) #滚球id本地存
@@ -20,4 +20,4 @@ execute(["scrapy", "crawl", "roll_lanqiu"]) #滚球篮球
 # execute(["scrapy", "crawl", "zq_jieshu"]) #滚球id结束时间更新状态
 # execute(["scrapy", "crawl", "lq_jieshu"]) #滚球id结束时间更新状态
 # execute(["scrapy", "crawl", "wq_jieshu"]) #滚球id结束时间更新状态
-# execute(["scrapy", "crawl", "bq_jieshu"]) #滚球id结束时间更新状态
+# execute(["scrapy", "crawl", "bq_jieshu"]) #滚球id结束时间更新状态

+ 9 - 9
hg3535/main_time.py

@@ -14,20 +14,20 @@ if can == 'roll':
     while True:
         os.system("scrapy crawl roll_zuqiu")
         time.sleep(2)
-        os.system("scrapy crawl zq_jieshu")
-        time.sleep(2)
+        # os.system("scrapy crawl zq_jieshu")
+        # time.sleep(2)
         os.system("scrapy crawl roll_lanqiu")
         time.sleep(2)
-        os.system("scrapy crawl lq_jieshu")
-        time.sleep(2)
+        # os.system("scrapy crawl lq_jieshu")
+        # time.sleep(2)
         os.system("scrapy crawl roll_wangqiu")
         time.sleep(2)
-        os.system("scrapy crawl wq_jieshu")
-        time.sleep(2)
+        # os.system("scrapy crawl wq_jieshu")
+        # time.sleep(2)
         os.system("scrapy crawl roll_bangqiu")
-        time.sleep(2)
-        os.system("scrapy crawl bq_jieshu")
-        time.sleep(30)
+        # time.sleep(2)
+        # os.system("scrapy crawl bq_jieshu")
+        time.sleep(120)
 
 if can == 'notroll':
     while True:

+ 2 - 1
hg3535/middlewares.py

@@ -140,7 +140,8 @@ class Hg3535timeoutDownloaderMiddleware(object):
             # # print("this is response ip:" + proxy)
             # # 对当前reque加上代理
             # request.meta['proxy'] = proxy
-            raise IgnoreRequest
+            # raise IgnoreRequest
+            return response
         return response
 
     def process_exception(self, request, exception, spider):

+ 28 - 0
hg3535/not_roll.py

@@ -0,0 +1,28 @@
+import time
+import os
+# from subprocess import Popen
+from apscheduler.schedulers.background import BackgroundScheduler
+# pip install apscheduler
+
+
+def notroll():
+    os.system("scrapy crawl liansai")
+    os.system("scrapy crawl zuqiu")
+    os.system("scrapy crawl wqbodan")
+    os.system("scrapy crawl wangqiu")
+    os.system("scrapy crawl lanqiu")
+    os.system("scrapy crawl guanjun")
+    os.system("scrapy crawl bangqiu")
+
+
+if __name__ == "__main__":
+    scheduler = BackgroundScheduler()
+    # 每20分钟执行一次
+    scheduler.add_job(notroll, 'cron', minute="*/10")
+    scheduler.start()
+    print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
+    try:
+        while True:
+            time.sleep(2)
+    except (KeyboardInterrupt, SystemExit):
+        scheduler.shutdown()

+ 478 - 0
hg3535/pipeline/ball_func.py

@@ -0,0 +1,478 @@
+import datetime
+import hashlib
+import time
+
+
+# # 生成哈希索引 sole
+# def hash_func(match_id, odds_code, sort, p_id):
+#     m = hashlib.md5()
+#     a = str(match_id) + str(odds_code) + str(sort) + str(p_id)
+#     m.update(a.encode('utf-8'))
+#     c = m.hexdigest()
+#     return c
+#
+#
+# # 生成odds_only哈希
+# def r_func(match_id, odds_code, sort, p_id, odd):
+#     m = hashlib.md5()
+#     a = str(match_id) + str(odds_code) + str(sort) + str(p_id) + str(odd)
+#     m.update(a.encode('utf-8'))
+#     c = m.hexdigest()
+#     return c
+
+
+# 转换成本地时间
+def new_time(ctime):
+    time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
+    time2 = time.localtime(time1)
+    time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
+    time4 = time3
+    data_time = str(time4).split(" ")
+    match_date = data_time[0]
+    match_time = data_time[1]
+    return match_date, match_time, time3
+
+
+def out_time(ctime, i):
+    ctime1 = datetime.datetime.strptime(ctime, "%Y-%m-%d %H:%M:%S")
+    n_ctime = (ctime1 + datetime.timedelta(hours=i)).strftime("%Y-%m-%d %H:%M:%S")
+    return n_ctime
+
+
+def fuhao(f):
+    if f.startswith('+'):
+        f = f.replace('+', '-')
+        return f
+    elif f.startswith('-'):
+        f = f.replace('-', '+')
+        return f
+    else:
+        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 new_times(ctime):
+#     time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
+#     time2 = time.localtime(time1)
+#     time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
+#     data_time = str(time3).split(" ")
+#     match_date = data_time[0]
+#     match_time = data_time[1]
+#     return match_date,match_time
+
+
+# def news_times(ctime):
+#     time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
+#     time2 = time.localtime(time1)
+#     time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
+#     time4 = time3
+#     data_time = str(time4).split(" ")
+#     match_date = data_time[0]
+#     match_time = data_time[1]
+#     return match_date, match_time, time3
+
+
+# def one_post(data, match_id, odds_code, p_id, league_id, p_code, condition, game_code, zq_odds):
+#     if data:
+#         new_hash = hash_func(match_id=match_id, odds_code=odds_code, sort=0, p_id=p_id)
+#         r_hash = r_func(match_id=match_id, odds_code=odds_code, sort=0, p_id=p_id, odd=data)
+#         payload = {
+#             "game_code": game_code,
+#             "title": "odds",
+#             "data": {
+#                 "match_id": match_id,
+#                 "lg_id": league_id,
+#                 "odds_code": odds_code,
+#                 "status": 0,
+#                 "sort": 0,
+#                 "p_code": p_code,
+#                 "odds": data,
+#                 "condition": condition,
+#                 "odds_only": r_hash,
+#                 "sole": new_hash,
+#                 "source": "hg3535",
+#                 "type": 0,
+#                 "team": ""
+#             }
+#         }
+#         zq_odds.append(payload)
+#         # return payload
+#
+#
+# def two_post(data, match_id, odds_code, p_id, league_id, p_code, condition, game_code, zq_odds):
+#     if data:
+#         # odds_list = []
+#         for index, value in enumerate(data):
+#             if value:
+#                 s_hash = hash_func(match_id=match_id, odds_code=odds_code, sort=index, p_id=p_id)
+#                 o_hash = r_func(match_id=match_id, odds_code=odds_code, sort=index, p_id=p_id, odd=value)
+#                 f1 = fuhao(str(condition[index]))
+#                 payload = {
+#                     "game_code": game_code,
+#                     "title": "odds",
+#                     "data": {
+#                         "match_id": match_id,
+#                         "lg_id": league_id,
+#                         "odds_code": odds_code,
+#                         "status": 0,
+#                         "sort": index,
+#                         "p_code": p_code,
+#                         "odds": value,
+#                         "condition": f1,
+#                         "odds_only": o_hash,
+#                         "sole": s_hash,
+#                         "source": "hg3535",
+#                         "type": 0,
+#                         "team": ""
+#                     }
+#                 }
+#                 zq_odds.append(payload)
+#         #         odds_list.append(payload)
+#         # return odds_list
+#
+#
+# def three_post(data, match_id, p_id, league_id, p_code, condition, game_code, zq_odds):
+#     if data:
+#         # odd_list = []
+#         for key, value in data.items():
+#             if value:
+#                 s_hash = hash_func(match_id=match_id, odds_code=key, sort=0, p_id=p_id)
+#                 o_hash = r_func(match_id=match_id, odds_code=key, sort=0, p_id=p_id, odd=value)
+#                 try:
+#                     f1 = fuhao(str(condition[key]))
+#                 except:
+#                     f1 = ""
+#                 payload = {
+#                     "game_code": game_code,
+#                     "title": "odds",
+#                     "data": {
+#                         "match_id": match_id,
+#                         "lg_id": league_id,
+#                         "odds_code": key,
+#                         "status": 0,
+#                         "sort": 0,
+#                         "p_code": p_code,
+#                         "odds": value,
+#                         "condition": f1,
+#                         "odds_only": o_hash,
+#                         "sole": s_hash,
+#                         "source": "hg3535",
+#                         "type": 0,
+#                         "team": ""
+#                     }
+#                 }
+#                 zq_odds.append(payload)
+#         #         odd_list.append(payload)
+#         # return odd_list
+#
+#
+# def gs_post(ball, league_id, league_name, data_game):
+#     if ball == "足球":
+#         n_gameid = int('1' + str(league_id))
+#         payload = {
+#             "game_code": "zq",
+#             "title": "competition",
+#             "data": {
+#                 "home_team": league_name,
+#                 "guest_team": "",
+#                 "lg_id": league_id,
+#                 "status": 0,
+#                 "match_id": n_gameid,
+#                 "source": "hg3535",
+#                 "us_time": data_game,
+#                 "match_date": "",
+#                 "match_time": "",
+#                 "tag": "",
+#                 "is_rollball": 0,
+#                 "is_today": 0,
+#                 "is_morningplate": 0,
+#                 "is_stringscene": 0,
+#                 }
+#         }
+#     elif ball == "篮球":
+#         n_gameid = int('1' + str(league_id))
+#         payload = {
+#             "game_code": "zq",
+#             "title": "competition",
+#             "data": {
+#                 "home_team": league_name,
+#                 "guest_team": "",
+#                 "lg_id": league_id,
+#                 "status": 0,
+#                 "match_id": n_gameid,
+#                 "source": "hg3535",
+#                 "us_time": data_game,
+#                 "match_date": "",
+#                 "match_time": "",
+#                 "tag": "",
+#                 "is_rollball": 0,
+#                 "is_today": 0,
+#                 "is_morningplate": 0,
+#                 "is_stringscene": 0,
+#             }
+#         }
+#     elif ball == "网球":
+#         n_gameid = int('1' + str(league_id))
+#         payload = {
+#             "game_code": "zq",
+#             "title": "competition",
+#             "data": {
+#                 "home_team": league_name,
+#                 "guest_team": "",
+#                 "lg_id": league_id,
+#                 "status": 0,
+#                 "match_id": n_gameid,
+#                 "source": "hg3535",
+#                 "us_time": data_game,
+#                 "match_date": "",
+#                 "match_time": "",
+#                 "tag": "",
+#                 "is_rollball": 0,
+#                 "is_today": 0,
+#                 "is_morningplate": 0,
+#                 "is_stringscene": 0,
+#             }
+#         }
+#     elif ball == "棒球":
+#         n_gameid = int('1' + str(league_id))
+#         payload = {
+#             "game_code": "zq",
+#             "title": "competition",
+#             "data": {
+#                 "home_team": league_name,
+#                 "guest_team": "",
+#                 "lg_id": league_id,
+#                 "status": 0,
+#                 "match_id": n_gameid,
+#                 "source": "hg3535",
+#                 "us_time": data_game,
+#                 "match_date": "",
+#                 "match_time": "",
+#                 "tag": "",
+#                 "is_rollball": 0,
+#                 "is_today": 0,
+#                 "is_morningplate": 0,
+#                 "is_stringscene": 0,
+#             }
+#         }
+#     return payload
+#
+#
+# def go_post(ball, league_id, new_champion, new_league_name, value, r_hash, new_hash, tema_home):
+#     game_id = int('1' + str(league_id))
+#     if ball == "足球":
+#         payload = {
+#             "game_code": "zq",
+#             "title": "odds",
+#             "data": {
+#                 "match_id": league_id,
+#                 "lg_id": game_id,
+#                 "odds_code": new_champion,
+#                 "status": 0,
+#                 "sort": 0,
+#                 "p_code": new_league_name,
+#                 "odds": value,
+#                 "condition": "",
+#                 "odds_only": r_hash,
+#                 "sole": new_hash,
+#                 "source": 'hg3535',
+#                 "type": 1,
+#                 "team": tema_home
+#             }
+#         }
+#     elif ball == "篮球":
+#         payload = {
+#             "game_code": "lq",
+#             "title": "odds",
+#             "data": {
+#                 "match_id": league_id,
+#                 "lg_id": game_id,
+#                 "odds_code": new_champion,
+#                 "status": 0,
+#                 "sort": 0,
+#                 "p_code": new_league_name,
+#                 "odds": value,
+#                 "condition": "",
+#                 "odds_only": r_hash,
+#                 "sole": new_hash,
+#                 "source": "hg3535",
+#                 "type": 1,
+#                 "team": tema_home
+#             }
+#         }
+#     elif ball == "网球":
+#         payload = {
+#             "game_code": "wq",
+#             "title": "odds",
+#             "data": {
+#                 "match_id": league_id,
+#                 "lg_id": game_id,
+#                 "odds_code": new_champion,
+#                 "status": 0,
+#                 "sort": 0,
+#                 "p_code": new_league_name,
+#                 "odds": value,
+#                 "condition": "",
+#                 "odds_only": r_hash,
+#                 "sole": new_hash,
+#                 "source": "hg3535",
+#                 "type": 1,
+#                 "team": tema_home
+#             }
+#         }
+#     elif ball == "棒球":
+#         payload = {
+#             "game_code": "bq",
+#             "title": "odds",
+#             "data": {
+#                 "match_id": league_id,
+#                 "lg_id": game_id,
+#                 "odds_code": new_champion,
+#                 "status": 0,
+#                 "sort": 0,
+#                 "p_code": new_league_name,
+#                 "odds": value,
+#                 "condition": "",
+#                 "odds_only": r_hash,
+#                 "sole": new_hash,
+#                 "source": "hg3535",
+#                 "type": 1,
+#                 "team": tema_home
+#             }
+#         }
+#     return payload
+#
+#
+# def guanl_post(ball, league_name, league_id, time3):
+#     if ball == "足球":
+#         payload = {
+#             "game_code": "zq",
+#             "title": "league",
+#             "data": {
+#                 "name_chinese": league_name,
+#                 "kind": "1",
+#                 "match_mode": "1",
+#                 "if_stop": "0",
+#                 # "belong": "",
+#                 "last_time": time3,
+#                 "lg_id": league_id,
+#                 "source": "hg3535"
+#                 }
+#             }
+#     elif ball == "篮球":
+#         payload = {
+#             "game_code": "zq",
+#             "title": "league",
+#             "data": {
+#                 "name_chinese": league_name,
+#                 "kind": "1",
+#                 "match_mode": "1",
+#                 "if_stop": "0",
+#                 # "belong": "",
+#                 "last_time": time3,
+#                 "lg_id": league_id,
+#                 "source": "hg3535"
+#             }
+#         }
+#     elif ball == "网球":
+#         payload = {
+#             "game_code": "zq",
+#             "title": "league",
+#             "data": {
+#                 "name_chinese": league_name,
+#                 "kind": "1",
+#                 "match_mode": "1",
+#                 "if_stop": "0",
+#                 # "belong": "",
+#                 "last_time": time3,
+#                 "lg_id": league_id,
+#                 "source": "hg3535"
+#             }
+#         }
+#     elif ball == "棒球":
+#         payload = {
+#             "game_code": "zq",
+#             "title": "league",
+#             "data": {
+#                 "name_chinese": league_name,
+#                 "kind": "1",
+#                 "match_mode": "1",
+#                 "if_stop": "0",
+#                 # "belong": "",
+#                 "last_time": time3,
+#                 "lg_id": league_id,
+#                 "source": "hg3535"
+#             }
+#         }
+#     return payload
+#
+#
+# def liansai(area_name, name_chinese, st_league, area_dict, game_code, qiu):
+#     if area_name in area_dict:
+#         payload = {
+#             "game_code": game_code,
+#             "title": "league",
+#             "data": {
+#                 "name_chinese": name_chinese,
+#                 "kind": "1",
+#                 "match_mode": "1",
+#                 "if_stop": "0",
+#                 "belong": area_name,
+#                 "last_time": '2019-12-31 23:59:59',
+#                 "lg_id": st_league,
+#                 "source": "hg3535"
+#             }
+#         }
+#     else:
+#         if area_name == qiu:
+#             payload = {
+#                 "game_code": game_code,
+#                 "title": "league",
+#                 "data": {
+#                     "name_chinese": name_chinese,
+#                     "kind": "1",
+#                     "match_mode": "1",
+#                     "if_stop": "0",
+#                     "belong": " ",
+#                     "last_time": '2019-12-31 23:59:59',
+#                     "lg_id": st_league,
+#                     "source": "hg3535"
+#                 }
+#             }
+#         else:
+#             payload = {
+#                 "game_code": game_code,
+#                 "title": "league",
+#                 "data": {
+#                     "name_chinese": name_chinese,
+#                     "kind": "1",
+#                     "match_mode": "1",
+#                     "if_stop": "0",
+#                     "belong": area_name,
+#                     "last_time": '2019-12-31 23:59:59',
+#                     "lg_id": st_league,
+#                     "source": "hg3535"
+#                 }}
+#     return payload
+

+ 110 - 0
hg3535/pipeline/guanjun.py

@@ -0,0 +1,110 @@
+# import datetime
+import pymongo
+import time
+import logging
+from ..utils.helper import Helper
+
+
+class Guanjunpipeline(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']
+
+    def process_item(self, item, spider):
+        gj_odds = []
+        url = 'http://admin.5gogo.com/'
+        logger = logging.getLogger(__name__)
+        data_game = item['data_game'].replace('年', "-").replace('月', "-").replace('日', "")
+        time_game = item['time_game']
+        ctime = data_game + " " + time_game + ":00"
+        uptime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
+        # expire_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + 60))
+        league_name = item['league_name']
+        tema_home = item['tema_home']
+        league_id = item['league_id']
+        match_id = item['game_id']
+        new_league_name = item['new_league_name']
+        # 冠军赔率
+        champion_team = round(item['champion_team'], 2)
+        # 冠军玩法
+        new_champion = item['new_champion']
+        # 构建唯一哈希索引
+        time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
+        time2 = time.localtime(time1)
+        time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
+        # pt = item['pt']
+        ball = item['ball']
+        if ball == '足球':
+            game_code = 'zq'
+            league_table = 'hg3535_zq_league'
+            odds_table = "hg3535_zq_chain_odds"
+        elif ball == '篮球':
+            game_code = 'lq'
+            league_table = 'hg3535_lq_league'
+            odds_table = "hg3535_lq_chain_odds"
+        elif ball == '网球':
+            game_code = 'wq'
+            league_table = "hg3535_wq_league"
+            odds_table = "hg3535_wq_chain_odds"
+        elif ball == '棒球':
+            game_code = 'bq'
+            league_table = "hg3535_bq_league"
+            odds_table = "hg3535_bq_chain_odds"
+        else:
+            print(ball, "冠军数据球类错误")
+            return
+        league_list = []
+        uuid = Helper.genearte_MD5(league_name + 'hg0088')
+        payload_key = ['game_code', 'title', 'match_id', 'lg_id', 'source']
+        payload_value = [game_code, 'league', match_id, league_id, 'hg3535']
+        l_payload = dict(zip(payload_key, payload_value))
+
+        league_key = ['name_chinese', 'kind', 'match_mode', 'if_stop', 'identity', 'belong', 'last_time',
+                      'lg_id', 'source', 'uuid']
+        league_value = [new_league_name, '0', '0', '0', uuid, '0', time3, league_id, 'hg3535', uuid]
+        league_dict = dict(zip(league_key, league_value))
+        if self.db[league_table].find({'uuid': uuid}).count() < 1:
+            league_list.append(league_dict)
+            l_payload['data'] = league_list
+            try:
+                print("冠军联赛数据不为空,数据提交")
+                response_data = Helper.async_post(url + '/setLeague', l_payload)
+                print(response_data)
+                print('请求冠军联赛成功')
+                logger.info('请求足球冠军联赛成功')
+            except Exception as e:
+                logger.warning('足球冠军联赛数据数据接口异常,提交失败')
+                logger.warning(e)
+            self.db[league_table].insert(league_list)
+        else:
+            print('冠军联赛数据已存在')
+
+        payload_key1 = ['game_code', 'title', 'source']
+        payload_value1 = [game_code, 'odds_ch', 'hg3535']
+        only_list = []
+        chain_dict = dict(zip(payload_key1, payload_value1))
+        sole = Helper.genearte_MD5(new_champion + str(league_id) + league_name + new_league_name + tema_home)
+        odds_only = Helper.genearte_MD5(new_champion + str(league_id) + league_name + new_league_name + str(champion_team) + tema_home + str(match_id))
+        only_list.append(odds_only)
+        data_key = ['match_id', 'lg_id', 'odds_code', 'status', 'sort', 'p_code', 'odds',
+                    'condition', 'odds_only', 'sole', 'source', 'type', 'team', 'uuid']
+        data_value = [match_id, league_id, new_champion, '0', '0', new_league_name, champion_team, '0', odds_only, sole, 'hg3535', '1', tema_home, uuid]
+        chain_data = dict(zip(data_key, data_value))
+        data_list = []
+        if self.db[odds_table].find({'odds_only': odds_only}).count() < 1:
+            data_list.append(chain_data)
+            chain_dict['data'] = data_list
+            chain_dict['odds_only'] = only_list
+            try:
+                response_data = Helper.async_post(url + '/setOddsCH', chain_dict)
+                # logger.warning(response_data.text)
+                print(odds_table, response_data)
+                print(odds_table, '请求冠军赔率成功')
+            except Exception as e:
+                logger.warning('冠军赔率接口异常,提交失败')
+                logger.warning(e)
+            self.db[odds_table].insert(chain_data)
+        else:
+            print('足球冠军已经提交过了')
+            logger.info('足球冠军已经提交过了')
+

+ 219 - 0
hg3535/pipeline/lanqiu.py

@@ -0,0 +1,219 @@
+import datetime
+import json
+import pymongo
+import time
+import logging
+import requests
+
+from ball_func import fuhao
+from ..utils.helper import Helper
+from .ball_func import get_pcode, new_time, out_time
+
+
+class Lanqiupipeline(object):
+    def process_item(self, item, spider):
+        # 使用twisted将mysql插入变成异步执行
+        lq_odds = []
+        url = 'http://admin.5gogo.com'
+        logger = logging.getLogger(__name__)
+        # # logger.warning(query.addErrback(self.handle_error, item, spider))
+        # 联赛id
+        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']
+        # 比赛状态
+        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])
+        # 比赛时间
+        time_game = str(item['time_game'])
+        # 比赛时间,时间戳
+        us_time = "2019" + "-" + month + "-" + day + " " + time_game + ":00"
+        r_ctime = "2019" + "-" + month + "-" + day
+        # 现在时间,时间戳
+        utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
+        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 = item['pt']
+        concedes_dict = item['concede']
+        concedes_dict_rule = item['concede_rule']
+        odd_evens_dict = item['odd_even']
+        odd_evens_dict_rule = item['odd_even_rule']
+        total_sizes_dict = item['total_size']
+        total_sizes_dict_rule = item['total_size_rule']
+        last_numbers_dict = item['last_number']
+        capots_dict = item['capot']
+        team_scores_dict = item['team_score']
+        team_scores_dict_rule = item['team_score_rule']
+        # 让球
+        lanqiu = item['lanqiu']
+        match_date, match_time, time3 = new_time(us_time)
+        # 让球 数据插入数据库
+        last_time = '2019-12-31 23:59:59'
+        league_dict = {"game_code": "lq", "title": "league", "source": "hg3535"}
+        league_list = []
+        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+        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
+        response_data = Helper.async_post(url + '/setLeague', league_dict)
+        print(response_data)
+        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
+        # 赛事接口写入
+        match_dict = {"game_code": "lq", "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, is_today]
+        match_list = []
+        match_data = dict(zip(match_kay, match_value))
+        match_list.append(match_data)
+        match_dict['data'] = match_list
+        response_data = Helper.async_post(url + '/setMatch', match_dict)
+        print(response_data)
+
+        # if concedes_dict:
+        #     for key, value in concedes_dict.items():
+        #         two_post(data=value, match_id=game_id, odds_code=key, p_id=1,
+        #                  league_id=league_id, p_code='concede', condition=concedes_dict_rule[key], game_code='lq', zq_odds=lq_odds)
+        # if odd_evens_dict:
+        #     for key, value in odd_evens_dict.items():
+        #         one_post(data=value, match_id=game_id, odds_code=key, p_id=2,
+        #                  league_id=league_id, p_code='two_sides', condition=odd_evens_dict_rule[key], game_code='lq', zq_odds=lq_odds)
+        # # 总分单双 数据插入数据库
+        # if total_sizes_dict:
+        #     for key, value in total_sizes_dict.items():
+        #         two_post(data=value, match_id=game_id, odds_code=key, p_id=3,
+        #                  league_id=league_id, p_code='total_size', condition=total_sizes_dict_rule[key], game_code='lq', zq_odds=lq_odds)
+        # # 全场总分大小 数据插入数据库
+        # # 全场总分大小 数据插入数据库
+        # if team_scores_dict:
+        #     for key, value in team_scores_dict.items():
+        #         two_post(data=value, match_id=game_id, odds_code=key, p_id=6,
+        #                  league_id=league_id, p_code='total_size', condition=team_scores_dict_rule[key], game_code='lq', zq_odds=lq_odds)
+        # lastnumber_dict = {'0或5': '_zero_five', '1或6': '_one_six', '2或7': '_two_seven', '3或8': '_three_eight', '4或9': '_four_nine'}
+        # if last_numbers_dict['last_home']:
+        #     for key, value in last_numbers_dict['last_home'].items():
+        #         one_post(data=value, match_id=game_id, odds_code="last_home" + lastnumber_dict[key], p_id=4,
+        #                  league_id=league_id, p_code='last_number', condition=key, game_code='lq', zq_odds=lq_odds)
+        # if last_numbers_dict['last_guest']:
+        #     for key, value in last_numbers_dict['last_guest'].items():
+        #         one_post(data=value, match_id=game_id, odds_code="last_guest" + lastnumber_dict[key], p_id=4,
+        #                  league_id=league_id, p_code='last_number', condition=key, game_code='lq', zq_odds=lq_odds)
+        # three_post(data=capots_dict, match_id=game_id, p_id=5, league_id=league_id, p_code='capot', condition="", game_code='lq', zq_odds=lq_odds)
+        # match_date, match_time, time3 = new_time(ctime)
+        # n_time = out_time(time3, 1.5)
+        # us_time = ctime
+        # if lanqiu == "篮球":
+        #     if pt == 1:
+        #         payload = {
+        #             "game_code": "lq",
+        #             "title": "competition",
+        #             "data": {
+        #                 "home_team": team_home,
+        #                 "guest_team": team_guest,
+        #                 "lg_id": league_id,
+        #                 "status": 0,
+        #                 "match_id": game_id,
+        #                 "match_date": match_date,
+        #                 "match_time": match_time,
+        #                 "tag": number,
+        #                 "source": "hg3535",
+        #                 "is_rollball": 0,
+        #                 "is_today": 1,
+        #                 "is_morningplate": 0,
+        #                 "is_stringscene": 0,
+        #                 "us_time": us_time
+        #             }
+        #         }
+        #     if pt == 2:
+        #         payload = {
+        #             "game_code": "lq",
+        #             "title": "competition",
+        #             "data": {
+        #                 "home_team": team_home,
+        #                 "guest_team": team_guest,
+        #                 "lg_id": league_id,
+        #                 "status": 0,
+        #                 "match_id": game_id,
+        #                 "match_date": match_date,
+        #                 "match_time": match_time,
+        #                 "tag": number,
+        #                 "source": "hg3535",
+        #                 "is_rollball": 0,
+        #                 "is_today": 0,
+        #                 "is_morningplate": 1,
+        #                 "is_stringscene": 0,
+        #                 "us_time": us_time
+        #             }
+        #         }
+        #     if pt == 3:
+        #         payload = {
+        #             "game_code": "lq",
+        #             "title": "competition",
+        #             "data": {
+        #                 "home_team": team_home,
+        #                 "guest_team": team_guest,
+        #                 "lg_id": league_id,
+        #                 "status": 0,
+        #                 "match_id": game_id,
+        #                 "match_date": match_date,
+        #                 "match_time": match_time,
+        #                 "tag": number,
+        #                 "source": "hg3535",
+        #                 "is_rollball": 0,
+        #                 "is_today": 0,
+        #                 "is_morningplate": 0,
+        #                 "is_stringscene": 1,
+        #                 "us_time": us_time
+        #             }
+        #         }
+        #     lq_odds.insert(0, payload)
+        # r = requests.post(url, data={"data": json.dumps(lq_odds)})
+        # # logger.warning(r.text)
+        # print(r.text)
+        # return item

+ 319 - 0
hg3535/pipeline/roll_lanqiu.py

@@ -0,0 +1,319 @@
+import pymongo
+import time
+import logging
+from ball_func import fuhao
+from ..utils.helper import Helper
+# from .ball_func import get_pcode, new_time
+
+
+class Roll_Lanqiupipeline(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']
+
+    def process_item(self, item, spider):
+        url = 'http://admin.5gogo.com'
+        roll_lq = []
+        # 使用twisted将mysql插入变成异步执行
+        logger = logging.getLogger(__name__)
+        # 联赛id
+        league_id = item['league_id']
+        # 联赛名
+        league_name = item['league_name']
+        # result = item['result']
+        # 比赛id
+        match_id = item['game_id']
+        # 球队1 #home_team
+        team_home = item['team_home']
+        # 球队2 # guest_team
+        team_guest = item['team_guest']
+        # 数量(97>)
+        number = item['number']
+        # 比赛状态
+        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])
+        # 比赛时间
+        time_game = str(item['time_game'])
+        # 比赛时间,时间戳
+        ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
+        r_ctime = "2019" + "-" + month + "-" + day
+        expire_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + 60))  # 过期时间
+        # 现在时间,时间戳
+        utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
+        # 队1分数
+        score_home = item['score_home']
+        # 队2分数
+        score_guest = item['score_guest']
+        # 第几节
+        jijie = item['jijie']
+        # 球队得分
+        qiudui = item['qiudui']
+        pt = 4
+        match_score = "{}:{}".format(score_home, score_guest)
+        concedes_dict = item['concede']
+        concedes_dict_rule = item['concede_rule']
+        odd_evens_dict = item['odd_even']
+        odd_evens_dict_rule = item['odd_even_rule']
+        total_sizes_dict = item['total_size']
+        total_sizes_dict_rule = item['total_size_rule']
+        last_numbers_dict = item['last_number']
+        capots_dict = item['capot']
+        team_scores_dict = item['team_score']
+        team_scores_dict_rule = item['team_score_rule']
+
+        last_time = "2019-12-31 23:59:59"
+        league_dict = {"game_code": "lq", "title": "league", "source": "hg3535"}
+        league_list = []
+        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+
+        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_lq_league.find({'lg_id': league_id}).count() < 1:
+            response_data = Helper.async_post(url + '/setLeague', league_dict)
+            print(response_data)
+            self.db.hg3535_lq_league.insert(league_list)
+        competition = self.db.hg3535_lq_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": "lq", "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, 1, match_id, match_date, match_time, number,
+                               "hg3535", 1, is_morningplate, is_stringscene, us_time, uuid, 0, is_today]
+                match_data = dict(zip(match_kay, match_value))
+                match_list.append(match_data)
+                match_dict['data'] = match_list
+                response_data = Helper.async_post(url + '/setMatch', match_dict)
+                self.db.hg3535_lq_competition.insert(match_list)
+                print(response_data)
+                self.db.hg3535_lq_competition.update({'match_id': str(match_id)},
+                                                     {"$set": {"is_rollball": 1, "status": 1}},
+                                                     upsert=True)
+            else:
+                print("篮球赛事已存在,篮球赛事状态时间未改变,不做修改")
+        else:
+            is_rollball = 1
+            is_today = 0
+            is_morningplate = 0
+            is_stringscene = 0
+            # 赛事接口写入
+            match_dict = {"game_code": "lq", "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, 1, match_id, r_ctime, "00:00", number, "hg3535",
+                           is_rollball, is_morningplate, is_stringscene, utime, uuid, 0, is_today]
+            match_data = dict(zip(match_kay, match_value))
+            match_list.append(match_data)
+            match_dict['data'] = match_list
+            response_data = Helper.async_post(url + '/setMatch', match_dict)
+            self.db.hg3535_lq_competition.insert(match_list)
+            print(response_data)
+        # 赔率
+        try:
+            result = self.db.hg3535_lq_odds.find_one({'match_id': match_id, 'pt': pt})
+            uuid_list = result['odds_only']
+        except:
+            uuid_list = []
+            result = ''
+        data_list = []
+        odds_onlys = []
+        if concedes_dict:
+            for key, value in concedes_dict.items():
+                if value:
+                    for index, concede_value in enumerate(value):
+                        hash_str = "concede" + key + str(index) + str(concedes_dict_rule[key][index]) + str(
+                            concede_value) + "hg3535" + str(match_id)
+                        sole_str = "concede" + "key" + str(index) + str(match_id) + "hg3535"
+                        odds_only = Helper.genearte_MD5(hash_str)
+                        sole = Helper.genearte_MD5(sole_str)
+                        odds_onlys.append(odds_only)
+                        concede_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                       "condition", "odds_only", "sole", "source", "type", "team"]
+                        condition = fuhao(concedes_dict_rule[key][index])
+                        concede_value = [match_id, league_id, key, "0", index, 'concede', concede_value, condition,
+                                         odds_only, sole, "hg3535", "0", ""]
+                        concede_data = dict(zip(concede_key, concede_value))
+                        if odds_only not in uuid_list:
+                            data_list.append(concede_data)
+        if total_sizes_dict:
+            for key, value in total_sizes_dict.items():
+                if value:
+                    for index, total_sizes_value in enumerate(value):
+                        condition = fuhao(total_sizes_dict_rule[key][index])
+                        hash_str = "total_size" + key + str(index) + str(condition) + str(
+                            total_sizes_value) + "hg3535" + str(match_id)
+                        sole_str = "total_size" + "key" + str(index) + str(match_id) + "hg3535"
+                        odds_only = Helper.genearte_MD5(hash_str)
+                        sole = Helper.genearte_MD5(sole_str)
+                        odds_onlys.append(odds_only)
+                        total_sizes_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                           "condition", "odds_only", "sole", "source", "type", "team"]
+                        total_sizes_value = [match_id, league_id, key, "0", index, 'total_size', total_sizes_value,
+                                             condition,
+                                             odds_only, sole, "hg3535", "0", ""]
+                        total_sizes_data = dict(zip(total_sizes_key, total_sizes_value))
+                        if odds_only not in uuid_list:
+                            data_list.append(total_sizes_data)
+        if odd_evens_dict:
+            for key, value in odd_evens_dict.items():
+                if value:
+                    condition = odd_evens_dict_rule[key]
+                    hash_str = "two_sides" + key + '0' + str(condition) + str(
+                        value) + "hg3535" + str(match_id)
+                    sole_str = "two_sides" + "key" + '0' + str(match_id) + "hg3535"
+                    odds_only = Helper.genearte_MD5(hash_str)
+                    sole = Helper.genearte_MD5(sole_str)
+                    odds_onlys.append(odds_only)
+                    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, 'two_sides', value,
+                                       condition, odds_only, sole, "hg3535", "0", ""]
+                    odd_evens_data = dict(zip(odd_evens_key, odd_evens_value))
+                    if odds_only not in uuid_list:
+                        data_list.append(odd_evens_data)
+
+        lastnumber_dict = {'0或5': '_zero_five', '1或6': '_one_six', '2或7': '_two_seven', '3或8': '_three_eight',
+                           '4或9': '_four_nine'}
+        last_home = last_numbers_dict['last_home']
+        if last_home:
+            for key, value in last_home.items():
+                # pass
+                odds_code = 'last_home' + lastnumber_dict[key]
+                condition = lastnumber_dict[key]
+                hash_str = "last_number" + odds_code + '0' + str(condition) + str(
+                    value) + "hg3535" + str(match_id)
+                sole_str = "last_number" + "key" + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                last_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                 "condition", "odds_only", "sole", "source", "type", "team"]
+                last_home_value = [match_id, league_id, odds_code, "0", 0, 'last_number', value,
+                                   condition, odds_only, sole, "hg3535", "0", ""]
+                last_home_data = dict(zip(last_home_key, last_home_value))
+                if odds_only not in uuid_list:
+                    data_list.append(last_home_data)
+
+        last_guest = last_numbers_dict['last_guest']
+        if last_guest:
+            for key, value in last_guest.items():
+                odds_code = 'last_guest' + lastnumber_dict[key]
+                condition = lastnumber_dict[key]
+                hash_str = "last_number" + odds_code + '0' + str(condition) + str(value) + "hg3535" + str(match_id)
+                sole_str = "last_number" + "key" + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                last_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                  "condition", "odds_only", "sole", "source", "type", "team"]
+                last_guest_value = [match_id, league_id, odds_code, "0", 0, 'last_number', value,
+                                    condition, odds_only, sole, "hg3535", "0", ""]
+                last_guest_data = dict(zip(last_guest_key, last_guest_value))
+                if odds_only not in uuid_list:
+                    data_list.append(last_guest_data)
+
+        if capots_dict:
+            for key, value in capots_dict.items():
+                if value:
+                    hash_str = "capot" + key + '0' + '0' + str(value) + "hg3535" + str(match_id)
+                    sole_str = "capot" + "key" + '0' + str(match_id) + "hg3535"
+                    odds_only = Helper.genearte_MD5(hash_str)
+                    sole = Helper.genearte_MD5(sole_str)
+                    odds_onlys.append(odds_only)
+                    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, 'capot', value,
+                                    "", odds_only, sole, "hg3535", "0", ""]
+                    capots_data = dict(zip(capots_key, capots_value))
+                    if odds_only not in uuid_list:
+                        data_list.append(capots_data)
+
+        if team_scores_dict:
+            for key, team_scores_value in team_scores_dict.items():
+                if team_scores_value:
+                    for index, value in enumerate(team_scores_value):
+                        hash_str = "team_score" + key + str(index) + str(team_scores_dict_rule[key][index]) + str(
+                            value) + "hg3535" + str(match_id)
+                        sole_str = "team_score" + "key" + str(index) + str(match_id) + "hg3535"
+                        odds_only = Helper.genearte_MD5(hash_str)
+                        sole = Helper.genearte_MD5(sole_str)
+                        odds_onlys.append(odds_only)
+                        team_scores_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                           "condition", "odds_only", "sole", "source", "type", "team"]
+                        condition = team_scores_dict_rule[key][index]
+                        team_scores_value = [match_id, league_id, key, "0", index, 'team_score', value, condition,
+                                             odds_only, sole, "hg3535", "0", ""]
+                        team_scores_data = dict(zip(team_scores_key, team_scores_value))
+                        if odds_only not in uuid_list:
+                            data_list.append(team_scores_data)
+
+        odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
+                    "is_stringscene", "utime", "pt"]
+        odds_value = ["lq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, number, uuid,
+                      0, utime, pt]
+        odds_dict = dict(zip(odds_key, odds_value))
+        if data_list:
+            # print(odds_dict)
+            response_data = Helper.async_post(url + '/setOdds', odds_dict)
+            # print(response_data)
+            print('篮球球赔率请求成功', response_data)
+            if "成功" in response_data:
+                if result:
+                    self.db.hg3535_lq_odds.update({'match_id': match_id, 'pt': pt}, {
+                        '$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
+                else:
+                    self.db.hg3535_lq_odds.insert(odds_dict)
+        data_list = []
+        lq_rball = {"home_team": team_home, "guest_team": team_guest,
+                    "lg_id": league_id, "home_rate": 0,
+                    "guest_rate": 0, "home_score": score_home,
+                    "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,
+                    "match_id": match_id, "p_code": ""}
+        data_list.append(lq_rball)
+        r_data_dict = {
+            "game_code": "lq",
+            "title": "match_result_r",
+            "source": "hg3535",
+            "data": data_list
+        }
+        if data_list:
+            try:
+                response_data = Helper.async_post(url + '/setMatchResult', r_data_dict)
+                # print(r_data_dict)
+                print("滚球篮球赛事结果post提交", response_data)
+            except Exception as e:
+                logger.warning('滚球数据接口异常,提交失败')
+                logger.warning(e)
+

+ 625 - 0
hg3535/pipeline/roll_zuqiu.py

@@ -0,0 +1,625 @@
+# import datetime
+import pymongo
+import time
+import logging
+from ball_func import fuhao
+from ..utils.helper import Helper
+from .ball_func import get_pcode
+
+
+# 滚球足球 插入
+class Roll_Zuqiupipeline(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']
+
+    def process_item(self, item, spider):
+        logger = logging.getLogger(__name__)
+        url = 'http://admin.5gogo.com'
+        pt = 4
+        roll_zq = []
+        # 比赛日期
+        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'])
+        # print(time_game)
+        # 比赛时间,时间戳
+        ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
+        r_ctime = "2019" + "-" + month + "-" + day
+        # 现在时间,时间戳
+        utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
+        expire_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + 60))
+        # 比赛id
+        match_id = item['game_id']
+        # 联赛id
+        league_id = item['league_id']
+        # 联赛name
+        league_name = item['league_name']
+        # 主队
+        team_home = item['team_home']
+        # 客队
+        team_guest = item['team_guest']
+        # number
+        number = item['number']
+        score_home = item['score_home']
+        score_guest = item['score_guest']
+        all_goal = int(score_home) + int(score_guest)
+        half_way = item['half_way']
+        # pt = item['pt']
+        match_score = "{}:{}".format(score_home,score_guest)
+        corner_ball = item['corner_ball']
+        last_time = '2019-12-31 23:59:59'
+        league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
+        league_list = []
+        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+
+        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_zq_league.find({'league_id': league_id}).count() < 1:
+            response_data = Helper.async_post(url + '/setLeague', league_dict)
+            print('足球联赛请求成功', response_data)
+            if "成功" in response_data:
+                self.db.hg3535_zq_league.insert(league_list)
+        competition = self.db.hg3535_zq_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 pt == '3':
+            if is_rollball != 1 or status != 1:
+                match_dict = {"game_code": "zq", "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, 1, match_id, match_date, match_time, number,
+                               "hg3535", 1, is_morningplate, is_stringscene, us_time, uuid, 0, is_today]
+                match_data = dict(zip(match_kay, match_value))
+                match_list.append(match_data)
+                match_dict['data'] = match_list
+                print(match_dict)
+                response_data = Helper.async_post(url + '/setMatch', match_dict)
+                print('足球赛事请求成功', response_data)
+                if "成功" in response_data:
+                    self.db.hg3535_zq_competition.update({'match_id': match_id}, {"$set": {"is_rollball": 1, "status": 1}},
+                                                         upsert=True)
+            else:
+                print("赛事已存在,赛事状态时间为改变,不做修改")
+        else:
+            is_rollball = 1
+            is_today = 0
+            is_morningplate = 0
+            is_stringscene = 0
+            # 赛事接口写入
+            match_dict = {"game_code": "zq", "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, 1, match_id, r_ctime, "00:00", number, "hg3535",
+                           is_rollball, is_morningplate, is_stringscene, utime, uuid, 0, is_today]
+            match_data = dict(zip(match_kay, match_value))
+            match_list.append(match_data)
+            match_dict['data'] = match_list
+            response_data = Helper.async_post(url + '/setMatch', match_dict)
+            print(match_dict)
+            print('足球赛事请求成功', response_data)
+            if "成功" in response_data:
+                self.db.hg3535_zq_competition.insert(match_list)
+            # print(response_data)
+        # 赔率
+        try:
+            result = self.db.hg3535_zq_odds.find_one({'match_id': match_id, 'pt': pt})
+            uuid_list = result['odds_only']
+        except:
+            uuid_list = []
+            result = ''
+        p_code, p_id = get_pcode(corner_ball, 'goal_size')
+        # 构建唯一索引
+        half_size_guest = item["half_size_guest"]
+        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']
+        data_list = []
+        odds_onlys = []
+
+        # half_size_guest
+        for index, value in enumerate(half_size_guest):
+            hash_str = p_code + "half_size_guest" + str(index) + str(half_size_guest_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "half_size_guest" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                   "odds_only", "sole", "source", "type", "team"]
+            condition = fuhao(half_size_guest_rule[index])
+            half_size_guest_value = [match_id, league_id, "half_size_guest", "0", index, p_code, value, condition,
+                                     odds_only, sole, "hg3535", "0", ""]
+            half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
+            if odds_only not in uuid_list:
+                data_list.append(half_size_guest_data)
+        # half_size_home
+        for index, value in enumerate(half_size_home):
+            hash_str = p_code + "half_size_home" + str(index) + str(half_size_home_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "half_size_home" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                  "odds_only", "sole", "source", "type", "team"]
+            condition = fuhao(half_size_home_rule[index])
+            half_size_home_value = [match_id, league_id, "half_size_guest", "0", index, p_code, value, condition,
+                                    odds_only, sole, "hg3535", "0", ""]
+            half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
+            if odds_only not in uuid_list:
+                data_list.append(half_size_home_data)
+
+        # 全场场大小
+        size_guest = item["size_guest"]
+        size_guest_rule = item["size_guest_rule"]
+        size_home = item["size_home"]
+        size_home_rule = item["size_home_rule"]
+        # size_home
+        for index, value in enumerate(size_home):
+            hash_str = p_code + "size_home" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
+                match_id)
+            sole_str = p_code + "size_home" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                             "odds_only", "sole", "source", "type", "team"]
+            condition = fuhao(size_home_rule[index])
+            size_home_value = [match_id, league_id, "size_home", "0", index, p_code, value, condition, odds_only,
+                               sole, "hg3535", "0", ""]
+            size_home_data = dict(zip(size_home_key, size_home_value))
+            if odds_only not in uuid_list:
+                data_list.append(size_home_data)
+        # size_guest
+        for index, value in enumerate(size_guest):
+            hash_str = p_code + "size_guest" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
+                match_id)
+            sole_str = p_code + "size_guest" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                              "odds_only", "sole", "source", "type", "team"]
+            condition = fuhao(size_guest_rule[index])
+            size_guest_value = [match_id, league_id, "size_guest", "0", index, p_code, value, condition, odds_only,
+                                sole, "hg3535", "0", ""]
+            size_home_data = dict(zip(size_guest_key, size_guest_value))
+            if odds_only not in uuid_list:
+                data_list.append(size_home_data)
+
+        p_code, p_id = get_pcode(corner_ball, 'concede')
+        half_concede_home_rule = item["half_concede_home_rule"]
+        half_concede_home = item["half_concede_home"]
+        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 + "half_concede_guest" + str(index) + str(half_concede_guest_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "half_concede_guest" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            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, "half_concede_guest", "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))
+            if odds_only not in uuid_list:
+                data_list.append(half_concede_guest_data)
+        # half_concede_home
+        for index, value in enumerate(half_concede_home):
+            hash_str = p_code + "half_concede_home" + str(index) + str(half_concede_home_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "half_concede_home" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            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, "half_concede_home", "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))
+            if odds_only not in uuid_list:
+                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 + "concede_guest" + str(index) + str(concede_guest_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "concede_guest" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            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[index])
+            concede_guest_value = [match_id, league_id, "concede_guest", "0", index, p_code, value, condition,
+                                   odds_only, sole, "hg3535", "0", ""]
+            concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
+            if odds_only not in uuid_list:
+                data_list.append(concede_guest_data)
+        # concede_home
+        for index, value in enumerate(concede_home):
+            hash_str = p_code + "concede_home" + str(index) + str(concede_home_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "concede_home" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            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, "concede_home", "0", index, p_code, value, condition, odds_only,
+                                  sole, "hg3535", "0", ""]
+            concede_guest_data = dict(zip(concede_home_key, concede_home_value))
+            if odds_only not in uuid_list:
+                data_list.append(concede_guest_data)
+
+        # 独赢----------------------------------------------------------------------------------------------------------
+        p_code, p_id = get_pcode(corner_ball, 'capot')
+        half_capot_home = item["half_capot_home"]
+        half_capot_guest = item["half_capot_guest"]
+        half_capot_dogfall = item["half_capot_dogfall"]
+        capot_home = item["capot_home"]
+        capot_guest = item["capot_guest"]
+        capot_dogfall = item["capot_dogfall"]
+
+        # half_capot_home
+        hash_str = p_code + "half_capot_home" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
+        sole_str = p_code + "half_capot_home" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                               "odds_only", "sole", "source", "type", "team"]
+        half_capot_home_value = [match_id, league_id, "half_capot_home", "0", 0, p_code, half_capot_home, '1',
+                                 odds_only, sole, "hg3535", "0", ""]
+        half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_capot_homet_data)
+
+        # half_capot_guest
+        hash_str = p_code + "half_capot_guest" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
+        sole_str = p_code + "half_capot_guest" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                "odds_only", "sole", "source", "type", "team"]
+        half_capot_guest_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, half_capot_guest, '2',
+                                  odds_only, sole, "hg3535", "0", ""]
+        half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_capot_guest_data)
+
+        # half_capot_dogfall
+        hash_str = p_code + "half_capot_dogfall" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
+        sole_str = p_code + "half_capot_dogfall" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                  "odds_only", "sole", "source", "type", "team"]
+        half_capot_dogfall_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, half_capot_dogfall, 'X',
+                                    odds_only, sole, "hg3535", "0", ""]
+        half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_capot_dogfall_data)
+        # capot_dogfall
+        hash_str = p_code + "capot_dogfall" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
+        sole_str = p_code + "capot_dogfall" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                             "odds_only", "sole", "source", "type", "team"]
+        capot_dogfall_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, capot_dogfall, 'X', odds_only,
+                               sole, "hg3535", "0", ""]
+        capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
+        if odds_only not in uuid_list:
+            data_list.append(capot_dogfall_data)
+
+        # capot_home
+        hash_str = p_code + "capot_home" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
+        sole_str = p_code + "capot_home" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                          "odds_only", "sole", "source", "type", "team"]
+        capot_home_value = [match_id, league_id, "half_capot_home", "0", 0, p_code, capot_home, '1',
+                            odds_only, sole, "hg3535", "0", ""]
+        capot_homet_data = dict(zip(capot_home_key, capot_home_value))
+        if odds_only not in uuid_list:
+            data_list.append(capot_homet_data)
+        # capot_guest
+        hash_str = p_code + "capot_guest" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
+        sole_str = p_code + "capot_guest" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        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, "half_capot_guest", "0", 0, p_code, capot_home, '2',
+                             odds_only, sole, "hg3535", "0", ""]
+        capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
+        if odds_only not in uuid_list:
+            data_list.append(capot_guest_data)
+
+        # 入球数单双-----------------------------------------------------------------------------------------------------
+        p_code, p_id = get_pcode(corner_ball, 'two_sides')
+        odd_even_odd = item["odd_even_odd"]
+        odd_even_even = item["odd_even_even"]
+        half_odd_even_odd = item["half_odd_even_odd"]
+        half_odd_even_even = item["half_odd_even_even"]
+
+        # odd_even_odd
+        hash_str = p_code + "two_sides_single" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
+        sole_str = p_code + "two_sides_single" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                      "odds_only", "sole", "source", "type", "team"]
+        single_value = [match_id, league_id, "two_sides_single", "0", 0, p_code, odd_even_odd, '单',
+                        odds_only, sole, "hg3535", "0", ""]
+        single_data = dict(zip(single_key, single_value))
+        if odds_only not in uuid_list:
+            data_list.append(single_data)
+        # odd_even_even
+        hash_str = p_code + "two_sides_double" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
+        sole_str = p_code + "two_sides_double" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                      "odds_only", "sole", "source", "type", "team"]
+        double_value = [match_id, league_id, "two_sides_double", "0", 0, p_code, odd_even_even, '双',
+                        odds_only, sole, "hg3535", "0", ""]
+        double_data = dict(zip(double_key, double_value))
+        if odds_only not in uuid_list:
+            data_list.append(double_data)
+        # half_odd_even_even
+        hash_str = p_code + "two_sides_double" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
+        sole_str = p_code + "two_sides_double" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                           "odds_only", "sole", "source", "type", "team"]
+        half_double_value = [match_id, league_id, "two_sides_double", "0", 0, p_code, half_odd_even_even, '双',
+                             odds_only, sole, "hg3535", "0", ""]
+        half_double_data = dict(zip(half_double_key, half_double_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_double_data)
+        # half_odd_even_odd
+        hash_str = p_code + "two_sides_single" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
+        sole_str = p_code + "two_sides_single" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                           "odds_only", "sole", "source", "type", "team"]
+        half_single_value = [match_id, league_id, "two_sides_single", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
+                             sole, "hg3535", "0", ""]
+        half_single_data = dict(zip(half_single_key, half_single_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_single_data)
+        # 总入球数 ------------------------------------------------------------------------------------------------------
+        p_code, p_id = get_pcode(corner_ball, 'total_goal')
+        total_goals = item['total_goal']
+        total_dict = {'total_goal_zero': '0-1', 'total_goal_two': '2-3', 'total_goal_four': '4-6',
+                      'total_goal_seven': '7或以上', 'half_total_goal_zero': '0', "half_total_goal_one": '1',
+                      "half_total_goal_two": '2', "half_total_goal_three": '3或以上'}
+        # 全场入球数 单双
+        # 上半场入球数 单双
+        for key, value in total_goals.items():
+            hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
+            sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                               "odds_only", "sole", "source", "type", "team"]
+            total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
+                                 sole, "hg3535", "0", ""]
+            total_goals_data = dict(zip(total_goals_key, total_goals_value))
+            if odds_only not in uuid_list:
+                data_list.append(total_goals_data)
+
+        # 全场半场 ------------------------------------------------------------------------------------------------------
+        half_fulls = item['half_full']
+        p_code, p_id = get_pcode(corner_ball, 'half_full')
+        full_dict = {"half_full_home_home": "主主", "half_full_home_dogfall": "主和",
+                     "half_full_home_guest": "主客", "half_full_dogfall_home": "和主",
+                     "half_full_dogfall_dogfall": "和和", "half_full_dogfall_guest": "和客",
+                     "half_full_guest_home": "客主", "half_full_guest_dogfall": "客和",
+                     "half_full_guest_guest": "客客"}
+        if half_fulls:
+            for key, value in half_fulls.items():
+                hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                  "odds_only", "sole", "source", "type", "team"]
+                half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
+                                    sole, "hg3535", "0", ""]
+                half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
+                if odds_only not in uuid_list:
+                    data_list.append(half_fulls_data)
+
+        # 波胆------------------------------------------------------------------------------------------------------------------
+        bodan_datas = item['bodan_data']
+        p_code, p_id = get_pcode(corner_ball, 'bodan')
+        bodan_dict = {"bodanhome_one_zero": "1-0", "bodanhome_two_zero": "2-0",
+                      "bodanhome_two_one": "2-1", "bodanhome_three_zero": "3-0",
+                      "bodanhome_three_one": "3-1", "bodanhome_three_two": "3-2",
+                      "bodanhome_four_zero": "4-0", "bodanhome_four_one": "4-1",
+                      "bodanhome_four_two": "4-2", "bodanhome_four_three": "4-3",
+                      "bodanguest_one_zero": "0-1", "bodanguest_two_zero": "0-2",
+                      "bodanguest_two_one": "1-2", "bodanguest_three_zero": "0-3",
+                      "bodanguest_three_one": "1-3", "bodanguest_three_two": "2-3",
+                      "bodanguest_four_zero": "0-4", "bodanguest_four_one": "1-4",
+                      "bodanguest_four_two": "2-4", "bodanguest_four_three": "3-4",
+                      "bodandogfall_zero_zero": "0-0", "bodandogfall_one_one": "1-1",
+                      "bodandogfall_two_two": "2-2", "bodandogfall_three_three": "3-3",
+                      "bodandogfall_four_four": "4-4", "bodanother": "其他",
+                      "halfbodanhome_one_zero": "1-0", "halfbodanhome_two_zero": "2-0",
+                      "halfbodanhome_two_one": "2-1", "halfbodanhome_three_zero": "3-0",
+                      "halfbodanhome_three_one": "3-1", "halfbodanhome_three_two": "3-2",
+                      "halfbodanguest_one_zero": "0-1", "halfbodanguest_two_zero": "0-2",
+                      "halfbodanguest_two_one": "1-2", "halfbodanguest_three_zero": "0-3",
+                      "halfbodanguest_three_one": "1-3", "halfbodanguest_three_two": "2-3",
+                      "halfbodandogfall_zero_zero": "0-0", "halfbodandogfall_one_one": "1-1",
+                      "halfbodandogfall_two_two": "2-2", "halfbodandogfall_three_three": "3-3",
+                      "halfbodanother": "其他"}
+        if bodan_datas:
+            for key, value in bodan_datas.items():
+                hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                  "odds_only", "sole", "source", "type", "team"]
+                bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
+                                    sole, "hg3535", "0", ""]
+                bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
+                if odds_only not in uuid_list:
+                    data_list.append(bodan_dict_data)
+
+        # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
+        first_last_balls = item['first_last_ball']
+        p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
+        first_last_dict = {"first_last_ball": "最先进球", "first_ball_home": "最先进球", "first_ball_guest": "最先进球",
+                           "last_ball_home": "最后进球", "last_ball_guest": "最后进球", "not_ball": "没有进球"}
+        if first_last_balls:
+            for key, value in first_last_balls.items():
+                hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                        "condition",
+                                        "odds_only", "sole", "source", "type", "team"]
+                first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key],
+                                          odds_only,
+                                          sole, "hg3535", "0", ""]
+                first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
+                if odds_only not in uuid_list:
+                    data_list.append(first_last_balls_data)
+
+        p_code, p_id = get_pcode(corner_ball, 'tema_ball')
+        full_dicts = item['full_data']
+        half_dicts = item['half_data']
+        full_dict_rules = item['full_data_rule']
+        half_dict_rules = item['half_data_rule']
+        if full_dicts:
+            for key, value in full_dicts.items():
+                hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                       "condition", "odds_only", "sole", "source", "type", "team"]
+                full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
+                                         odds_only, sole, "hg3535", "0", ""]
+                full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
+                if odds_only not in uuid_list:
+                    data_list.append(full_dict_rules_data)
+
+        if half_dicts:
+            for key, value in half_dicts.items():
+                hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                  "condition", "odds_only", "sole", "source", "type", "team"]
+                half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
+                                    odds_only, sole, "hg3535", "0", ""]
+                half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
+                if odds_only not in uuid_list:
+                    data_list.append(half_dicts_data)
+        odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
+                    "is_stringscene", "utime", "pt"]
+        odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, number, uuid,
+                      0, utime, pt]
+        odds_dict = dict(zip(odds_key, odds_value))
+        if data_list:
+            # print(odds_dict)
+            response_data = Helper.async_post(url + '/setOdds', odds_dict)
+            # print(response_data)
+            print('足球赔率请求成功', response_data)
+            if "成功" in response_data:
+                if result:
+                    self.db.hg3535_zq_odds.update({'match_id': match_id, 'pt': pt}, {
+                        '$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
+                else:
+                    self.db.hg3535_zq_odds.insert(odds_dict)
+        data_list = []
+        zq_rball = {"home_team": team_home, "guest_team": team_guest,
+                    "lg_id": league_id, "home_rate": 0,
+                    "guest_rate": 0, "home_score": score_home,
+                    "guest_score": score_guest, "all_goal": all_goal, "status": 1,
+                    "first_score": "", "last_score": "", "match_score": match_score, "uuid": uuid,
+                    "match_winer": "", "match_time": time_game,
+                    "match_process": half_way, "tag": number,
+                    "match_id": match_id, "p_code": ""}
+        data_list.append(zq_rball)
+        r_data_dict = {
+            "game_code": "zq",
+            "title": "match_result_r",
+            "source": "hg3535",
+            "data": data_list
+        }
+        if data_list:
+            try:
+                response_data = Helper.async_post(url + '/setMatchResult', r_data_dict)
+                print(r_data_dict)
+                print("滚球赛事结果post提交", response_data)
+            except Exception as e:
+                logger.warning('滚球数据接口异常,提交失败')
+                logger.warning(e)
+
+
+

+ 636 - 0
hg3535/pipeline/zuqiu.py

@@ -0,0 +1,636 @@
+import datetime
+import pymongo
+import time
+import logging
+from ball_func import fuhao
+from ..utils.helper import Helper
+from .ball_func import get_pcode, new_time
+from concurrent.futures import ThreadPoolExecutor
+from requests_futures.sessions import FuturesSession
+
+
+class Zuqiupipeline(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))
+
+    def process_item(self, item, spider):
+        zq_odds = []
+        # url = 'http://192.168.2.200:9093'
+        url = 'http://admin.5gogo.com'
+        # zq_competitions = []
+        logger = logging.getLogger(__name__)
+        # 比赛日期
+        try:
+            data_game = item['data_game'].split("/")
+            # print(data_game)
+            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'])
+        # 比赛时间,时间戳
+        # datetime.datetime.now().year
+        us_time = str(datetime.datetime.now().year) + "-" + month + "-" + day + " " + time_game + ":00"
+        r_ctime = str(datetime.datetime.now().year) + "-" + month + "-" + day
+        # 现在时间,时间戳
+        utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
+        expire_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + 60))
+        # 比赛id
+        match_id = item['game_id']
+        # 联赛id
+        league_id = item['league_id']
+        # 联赛name
+        league_name = item['league_name']
+        # # 主队
+        team_home = item['team_home']
+        # 客队
+        team_guest = item['team_guest']
+        # number
+        tag_number = item['number']
+        pt = item['pt']
+        corner_ball = item['corner_ball']
+        match_date, match_time, time3 = new_time(us_time)
+        # 联赛接口写入
+        last_time = '2019-12-31 23:59:59'
+        league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
+        league_list = []
+        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+
+        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_zq_league.find({'lg_id': league_id}).count() < 1:
+            response_data = Helper.async_post(url + '/setLeague', league_dict)
+            print(response_data)
+            self.db.hg3535_zq_league.insert(league_list)
+        competition = self.db.hg3535_zq_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": "zq", "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, 1, us_time, uuid, 0, is_today]
+                    match_data = dict(zip(match_kay, match_value))
+                    match_list.append(match_data)
+                    match_dict['data'] = match_list
+                    response_data = Helper.async_post(url + '/setMatch', match_dict)
+                    print(response_data)
+                    self.db.hg3535_zq_competition.update({'match_id': str(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": "zq", "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, 1, is_stringscene, us_time, uuid, 0, is_today]
+                    match_data = dict(zip(match_kay, match_value))
+                    match_list.append(match_data)
+                    match_dict['data'] = match_list
+                    response_data = Helper.async_post(url + '/setMatch', match_dict)
+                    print(response_data)
+                    self.db.hg3535_zq_competition.update({'match_id': str(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": "zq", "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
+                    response_data = Helper.async_post(url + '/setMatch', match_dict)
+                    print(response_data)
+                    self.db.hg3535_zq_competition.update({'match_id': str(match_id)}, {"$set": {"is_today": 1, "match_time": match_time}}, upsert=True)
+
+            else:
+                print("赛事已存在,赛事状态时间为改变,不做修改")
+        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
+            # 赛事接口写入
+            match_dict = {"game_code": "zq", "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, is_today]
+            match_data = dict(zip(match_kay, match_value))
+            match_list.append(match_data)
+            match_dict['data'] = match_list
+            response_data = Helper.async_post(url + '/setMatch', match_dict)
+            self.db.hg3535_zq_competition.insert(match_list)
+            print(response_data)
+        # 赔率
+        try:
+            result = self.db.hg3535_zq_odds.find_one({'match_id': match_id, 'pt': pt})
+            uuid_list = result['odds_only']
+        except:
+            uuid_list = []
+            result = ''
+        p_code, p_id = get_pcode(corner_ball, 'goal_size')
+        # 构建唯一索引
+        half_size_guest = item["half_size_guest"]
+        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']
+        data_list = []
+        odds_onlys = []
+        # half_size_guest
+        for index, value in enumerate(half_size_guest):
+            hash_str = p_code + "half_size_guest" + str(index) + str(half_size_guest_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "half_size_guest" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                   "odds_only", "sole", "source", "type", "team"]
+            condition = fuhao(half_size_guest_rule[index])
+            half_size_guest_value = [match_id, league_id, "half_size_guest", "0", index, p_code, value, condition,
+                                     odds_only, sole, "hg3535", "0", ""]
+            half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
+            if odds_only not in uuid_list:
+                data_list.append(half_size_guest_data)
+        # half_size_home
+        for index, value in enumerate(half_size_home):
+            hash_str = p_code + "half_size_home" + str(index) + str(half_size_home_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "half_size_home" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                  "odds_only", "sole", "source", "type", "team"]
+            condition = fuhao(half_size_home_rule[index])
+            half_size_home_value = [match_id, league_id, "half_size_guest", "0", index, p_code, value, condition,
+                                    odds_only, sole, "hg3535", "0", ""]
+            half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
+            # if uid_num < 1:
+            if odds_only not in uuid_list:
+                data_list.append(half_size_home_data)
+
+        # 全场场大小
+        size_guest = item["size_guest"]
+        size_guest_rule = item["size_guest_rule"]
+        size_home = item["size_home"]
+        size_home_rule = item["size_home_rule"]
+        # size_home
+        for index, value in enumerate(size_home):
+            hash_str = p_code + "size_home" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
+                match_id)
+            sole_str = p_code + "size_home" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                             "odds_only", "sole", "source", "type", "team"]
+            condition = fuhao(size_home_rule[index])
+            size_home_value = [match_id, league_id, "size_home", "0", index, p_code, value, condition, odds_only,
+                               sole, "hg3535", "0", ""]
+            size_home_data = dict(zip(size_home_key, size_home_value))
+            if odds_only not in uuid_list:
+                data_list.append(size_home_data)
+        # size_guest
+        for index, value in enumerate(size_guest):
+            hash_str = p_code + "size_guest" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
+                match_id)
+            sole_str = p_code + "size_guest" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                              "odds_only", "sole", "source", "type", "team"]
+            condition = fuhao(size_guest_rule[index])
+            size_guest_value = [match_id, league_id, "size_guest", "0", index, p_code, value, condition, odds_only,
+                                sole, "hg3535", "0", ""]
+            size_home_data = dict(zip(size_guest_key, size_guest_value))
+            if odds_only not in uuid_list:
+                data_list.append(size_home_data)
+
+        p_code, p_id = get_pcode(corner_ball, 'concede')
+        half_concede_home_rule = item["half_concede_home_rule"]
+        half_concede_home = item["half_concede_home"]
+        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 + "half_concede_guest" + str(index) + str(half_concede_guest_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "half_concede_guest" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            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, "half_concede_guest", "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))
+            # if uid_num < 1:
+            if odds_only not in uuid_list:
+                data_list.append(half_concede_guest_data)
+        # half_concede_home
+        for index, value in enumerate(half_concede_home):
+            hash_str = p_code + "half_concede_home" + str(index) + str(half_concede_home_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "half_concede_home" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            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, "half_concede_home", "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))
+            if odds_only not in uuid_list:
+                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 + "concede_guest" + str(index) + str(concede_guest_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "concede_guest" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            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[index])
+            concede_guest_value = [match_id, league_id, "concede_guest", "0", index, p_code, value, condition,
+                                   odds_only, sole, "hg3535", "0", ""]
+            concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
+            if odds_only not in uuid_list:
+                data_list.append(concede_guest_data)
+        # concede_home
+        for index, value in enumerate(concede_home):
+            hash_str = p_code + "concede_home" + str(index) + str(concede_home_rule[index]) + str(
+                value) + "hg3535" + str(match_id)
+            sole_str = p_code + "concede_home" + str(index) + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            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, "concede_home", "0", index, p_code, value, condition, odds_only,
+                                  sole, "hg3535", "0", ""]
+            concede_guest_data = dict(zip(concede_home_key, concede_home_value))
+            if odds_only not in uuid_list:
+                data_list.append(concede_guest_data)
+
+        # 独赢----------------------------------------------------------------------------------------------------------
+        p_code, p_id = get_pcode(corner_ball, 'capot')
+        half_capot_home = item["half_capot_home"]
+        half_capot_guest = item["half_capot_guest"]
+        half_capot_dogfall = item["half_capot_dogfall"]
+        capot_home = item["capot_home"]
+        capot_guest = item["capot_guest"]
+        capot_dogfall = item["capot_dogfall"]
+
+        # half_capot_home
+        hash_str = p_code + "half_capot_home" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
+        sole_str = p_code + "half_capot_home" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                               "odds_only", "sole", "source", "type", "team"]
+        half_capot_home_value = [match_id, league_id, "half_capot_home", "0", 0, p_code, half_capot_home, '1',
+                                 odds_only, sole, "hg3535", "0", ""]
+        half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_capot_homet_data)
+
+        # half_capot_guest
+        hash_str = p_code + "half_capot_guest" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
+        sole_str = p_code + "half_capot_guest" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                "odds_only", "sole", "source", "type", "team"]
+        half_capot_guest_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, half_capot_guest, '2',
+                                  odds_only, sole, "hg3535", "0", ""]
+        half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_capot_guest_data)
+
+        # half_capot_dogfall
+        hash_str = p_code + "half_capot_dogfall" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
+        sole_str = p_code + "half_capot_dogfall" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                  "odds_only", "sole", "source", "type", "team"]
+        half_capot_dogfall_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, half_capot_dogfall, 'X',
+                                    odds_only, sole, "hg3535", "0", ""]
+        half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_capot_dogfall_data)
+
+        # capot_dogfall
+        hash_str = p_code + "capot_dogfall" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
+        sole_str = p_code + "capot_dogfall" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                             "odds_only", "sole", "source", "type", "team"]
+        capot_dogfall_value = [match_id, league_id, "half_capot_guest", "0", 0, p_code, capot_dogfall, 'X', odds_only,
+                               sole, "hg3535", "0", ""]
+        capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
+        if odds_only not in uuid_list:
+            data_list.append(capot_dogfall_data)
+
+        # capot_home
+        hash_str = p_code + "capot_home" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
+        sole_str = p_code + "capot_home" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                          "odds_only", "sole", "source", "type", "team"]
+        capot_home_value = [match_id, league_id, "half_capot_home", "0", 0, p_code, capot_home, '1',
+                            odds_only, sole, "hg3535", "0", ""]
+        capot_homet_data = dict(zip(capot_home_key, capot_home_value))
+        if odds_only not in uuid_list:
+            data_list.append(capot_homet_data)
+
+        # capot_guest
+        hash_str = p_code + "capot_guest" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
+        sole_str = p_code + "capot_guest" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        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, "half_capot_guest", "0", 0, p_code, capot_home, '2',
+                             odds_only, sole, "hg3535", "0", ""]
+        capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
+        if odds_only not in uuid_list:
+            data_list.append(capot_guest_data)
+
+        # 入球数单双-----------------------------------------------------------------------------------------------------
+        p_code, p_id = get_pcode(corner_ball, 'two_sides')
+        odd_even_odd = item["odd_even_odd"]
+        odd_even_even = item["odd_even_even"]
+        half_odd_even_odd = item["half_odd_even_odd"]
+        half_odd_even_even = item["half_odd_even_even"]
+
+        # odd_even_odd
+        hash_str = p_code + "two_sides_single" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
+        sole_str = p_code + "two_sides_single" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                      "odds_only", "sole", "source", "type", "team"]
+        single_value = [match_id, league_id, "two_sides_single", "0", 0, p_code, odd_even_odd, '单',
+                        odds_only, sole, "hg3535", "0", ""]
+        single_data = dict(zip(single_key, single_value))
+        if odds_only not in uuid_list:
+            data_list.append(single_data)
+
+        # odd_even_even
+        hash_str = p_code + "two_sides_double" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
+        sole_str = p_code + "two_sides_double" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                      "odds_only", "sole", "source", "type", "team"]
+        double_value = [match_id, league_id, "two_sides_double", "0", 0, p_code, odd_even_even, '双',
+                        odds_only, sole, "hg3535", "0", ""]
+        double_data = dict(zip(double_key, double_value))
+        if odds_only not in uuid_list:
+            data_list.append(double_data)
+
+        # half_odd_even_even
+        hash_str = p_code + "two_sides_double" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
+        sole_str = p_code + "two_sides_double" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                           "odds_only", "sole", "source", "type", "team"]
+        half_double_value = [match_id, league_id, "two_sides_double", "0", 0, p_code, half_odd_even_even, '双',
+                             odds_only, sole, "hg3535", "0", ""]
+        half_double_data = dict(zip(half_double_key, half_double_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_double_data)
+
+        # half_odd_even_odd
+        hash_str = p_code + "two_sides_single" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
+        sole_str = p_code + "two_sides_single" + '0' + str(match_id) + "hg3535"
+        odds_only = Helper.genearte_MD5(hash_str)
+        sole = Helper.genearte_MD5(sole_str)
+        odds_onlys.append(odds_only)
+        half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                           "odds_only", "sole", "source", "type", "team"]
+        half_single_value = [match_id, league_id, "two_sides_single", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
+                             sole, "hg3535", "0", ""]
+        half_single_data = dict(zip(half_single_key, half_single_value))
+        if odds_only not in uuid_list:
+            data_list.append(half_single_data)
+
+        # 总入球数 ------------------------------------------------------------------------------------------------------
+        p_code, p_id = get_pcode(corner_ball, 'total_goal')
+        total_goals = item['total_goal']
+        total_dict = {'total_goal_zero': '0-1', 'total_goal_two': '2-3', 'total_goal_four': '4-6',
+                      'total_goal_seven': '7或以上', 'half_total_goal_zero': '0', "half_total_goal_one": '1',
+                      "half_total_goal_two": '2', "half_total_goal_three": '3或以上'}
+        # 全场入球数 单双
+        # 上半场入球数 单双
+        for key, value in total_goals.items():
+            hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
+            sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+            odds_only = Helper.genearte_MD5(hash_str)
+            sole = Helper.genearte_MD5(sole_str)
+            odds_onlys.append(odds_only)
+            total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                               "odds_only", "sole", "source", "type", "team"]
+            total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
+                                 sole, "hg3535", "0", ""]
+            total_goals_data = dict(zip(total_goals_key, total_goals_value))
+            if odds_only not in uuid_list:
+                data_list.append(total_goals_data)
+
+        # 全场半场 ------------------------------------------------------------------------------------------------------
+        half_fulls = item['half_full']
+        p_code, p_id = get_pcode(corner_ball, 'half_full')
+        full_dict = {"half_full_home_home": "主主", "half_full_home_dogfall": "主和",
+                     "half_full_home_guest": "主客", "half_full_dogfall_home": "和主",
+                     "half_full_dogfall_dogfall": "和和", "half_full_dogfall_guest": "和客",
+                     "half_full_guest_home": "客主", "half_full_guest_dogfall": "客和",
+                     "half_full_guest_guest": "客客"}
+        if half_fulls:
+            for key, value in half_fulls.items():
+                hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                   "odds_only", "sole", "source", "type", "team"]
+                half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
+                                     sole, "hg3535", "0", ""]
+                half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
+                if odds_only not in uuid_list:
+                    data_list.append(half_fulls_data)
+
+        # 波胆------------------------------------------------------------------------------------------------------------------
+        bodan_datas = item['bodan_data']
+        p_code, p_id = get_pcode(corner_ball, 'bodan')
+        bodan_dict = {"bodanhome_one_zero": "1-0", "bodanhome_two_zero": "2-0",
+                      "bodanhome_two_one": "2-1", "bodanhome_three_zero": "3-0",
+                      "bodanhome_three_one": "3-1", "bodanhome_three_two": "3-2",
+                      "bodanhome_four_zero": "4-0", "bodanhome_four_one": "4-1",
+                      "bodanhome_four_two": "4-2", "bodanhome_four_three": "4-3",
+                      "bodanguest_one_zero": "0-1", "bodanguest_two_zero": "0-2",
+                      "bodanguest_two_one": "1-2", "bodanguest_three_zero": "0-3",
+                      "bodanguest_three_one": "1-3", "bodanguest_three_two": "2-3",
+                      "bodanguest_four_zero": "0-4", "bodanguest_four_one": "1-4",
+                      "bodanguest_four_two": "2-4", "bodanguest_four_three": "3-4",
+                      "bodandogfall_zero_zero": "0-0", "bodandogfall_one_one": "1-1",
+                      "bodandogfall_two_two": "2-2", "bodandogfall_three_three": "3-3",
+                      "bodandogfall_four_four": "4-4", "bodanother": "其他",
+                      "halfbodanhome_one_zero": "1-0", "halfbodanhome_two_zero": "2-0",
+                      "halfbodanhome_two_one": "2-1", "halfbodanhome_three_zero": "3-0",
+                      "halfbodanhome_three_one": "3-1", "halfbodanhome_three_two": "3-2",
+                      "halfbodanguest_one_zero": "0-1", "halfbodanguest_two_zero": "0-2",
+                      "halfbodanguest_two_one": "1-2", "halfbodanguest_three_zero": "0-3",
+                      "halfbodanguest_three_one": "1-3", "halfbodanguest_three_two": "2-3",
+                      "halfbodandogfall_zero_zero": "0-0", "halfbodandogfall_one_one": "1-1",
+                      "halfbodandogfall_two_two": "2-2", "halfbodandogfall_three_three": "3-3",
+                      "halfbodanother": "其他"}
+        if bodan_datas:
+            for key, value in bodan_datas.items():
+                hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                  "odds_only", "sole", "source", "type", "team"]
+                bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
+                                    sole, "hg3535", "0", ""]
+                bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
+                if odds_only not in uuid_list:
+                    data_list.append(bodan_dict_data)
+
+        # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
+        first_last_balls = item['first_last_ball']
+        p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
+        first_last_dict = {"first_last_ball": "最先进球", "first_ball_home": "最先进球", "first_ball_guest": "最先进球",
+                           "last_ball_home": "最后进球", "last_ball_guest": "最后进球", "not_ball": "没有进球"}
+        if first_last_balls:
+            for key, value in first_last_balls.items():
+                hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
+                                  "odds_only", "sole", "source", "type", "team"]
+                first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key], odds_only,
+                                    sole, "hg3535", "0", ""]
+                first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
+                if odds_only not in uuid_list:
+                    data_list.append(first_last_balls_data)
+
+        p_code, p_id = get_pcode(corner_ball, 'tema_ball')
+        full_dicts = item['full_data']
+        half_dicts = item['half_data']
+        full_dict_rules = item['full_data_rule']
+        half_dict_rules = item['half_data_rule']
+        if full_dicts:
+            for key, value in full_dicts.items():
+                hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                        "condition", "odds_only", "sole", "source", "type", "team"]
+                full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
+                                          odds_only,sole, "hg3535", "0", ""]
+                full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
+                if odds_only not in uuid_list:
+                    data_list.append(full_dict_rules_data)
+        #
+        if half_dicts:
+            for key, value in half_dicts.items():
+                hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
+                sole_str = p_code + key + '0' + str(match_id) + "hg3535"
+                odds_only = Helper.genearte_MD5(hash_str)
+                sole = Helper.genearte_MD5(sole_str)
+                odds_onlys.append(odds_only)
+                half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
+                                "condition","odds_only", "sole", "source", "type", "team"]
+                half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
+                                         odds_only, sole, "hg3535", "0", ""]
+                half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
+                if odds_only not in uuid_list:
+                    data_list.append(half_dicts_data)
+        if pt == '3':
+            ris_stringscene = 1
+        else:
+            ris_stringscene = 0
+        odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid", "is_stringscene", "utime", "pt"]
+        odds_value = ["zq", "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))
+        if data_list:
+            # print(odds_dict)
+            response_data = Helper.async_post(url + '/setOdds', odds_dict)
+            print(response_data)
+            if "成功" in response_data:
+                if result:
+                    self.db.hg3535_zq_odds.update({'match_id': match_id, 'pt': pt}, {'$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
+                else:
+                    self.db.hg3535_zq_odds.insert(odds_dict)

File diff suppressed because it is too large
+ 427 - 543
hg3535/pipelines.py


+ 33 - 0
hg3535/roll.py

@@ -0,0 +1,33 @@
+import time
+import os
+import subprocess
+# import sys
+# from datetime import time
+# from subprocess import Popen
+# pip install apscheduler
+from apscheduler.schedulers.background import BackgroundScheduler
+
+
+def roll():
+    # execute("scrapy crawl roll_zuqiu")
+    os.system("scrapy crawl roll_zuqiu")
+    # os.system("scrapy crawl zq_jieshu")
+    os.system("scrapy crawl roll_lanqiu")
+    # os.system("scrapy crawl lq_jieshu")
+    os.system("scrapy crawl roll_wangqiu")
+    # os.system("scrapy crawl wq_jieshu")
+    os.system("scrapy crawl roll_bangqiu")
+    # pass
+
+
+if __name__ == "__main__":
+    scheduler = BackgroundScheduler()
+    # 每20分钟执行一次
+    scheduler.add_job(roll, 'cron', minute="*/3")
+    scheduler.start()
+    print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
+    try:
+        while True:
+            time.sleep(2)
+    except (KeyboardInterrupt, SystemExit):
+        scheduler.shutdown()

+ 18 - 15
hg3535/settings.py

@@ -74,23 +74,23 @@ DOWNLOADER_MIDDLEWARES = {
 #    'scrapy.extensions.telnet.TelnetConsole': None,
 #}
 
-# Configure item pipelines
+# Configure item pipeline
 # See https://doc.scrapy.org/en/latest/topics/item-pipeline.html
 ITEM_PIPELINES = {
    # # 篮球
-   # 'hg3535.pipelines.Lanqiupipeline': 300,
+   # 'hg3535.pipeline.Lanqiupipeline': 300,
    # # 冠军
-   # 'hg3535.pipelines.Guanjunpipeline': 300,
+   # 'hg3535.pipeline.Guanjunpipeline': 300,
    # # 联赛
-   # 'hg3535.pipelines.Liansaipipeline': 300,
+   # 'hg3535.pipeline.Liansaipipeline': 300,
    # # 足球
-   # 'hg3535.pipelines.Zuqiupipeline': 300,
+   # 'hg3535.pipeline.Zuqiupipeline': 300,
    # # 网球
-   # "hg3535.pipelines.Wangqiupipeline": 300,
+   # "hg3535.pipeline.Wangqiupipeline": 300,
    # # 网球波胆
-   # 'hg3535.pipelines.Wqbodanpipeline': 300,
+   # 'hg3535.pipeline.Wqbodanpipeline': 300,
    # # 棒球让球&大小盘
-   # "hg3535.pipelines.Bangqiupipeline": 300,
+   # "hg3535.pipeline.Bangqiupipeline": 300,
 }
 
 # Enable and configure the AutoThrottle extension (disabled by default)
@@ -125,6 +125,9 @@ REDIRECT_ENABLED = False
 
 SCHEDULER_PERSIST = False  # 是否在关闭时候保留原来的调度器和去重记录,True=保留,False=清空
 SCHEDULER_FLUSH_ON_START = False
+TELNETCONSOLE_PORT = None
+# TELNETCONSOLE_ENABLED=False
+# AttributeError: 'TelnetConsole' object has no attribute 'port'
 
 # RETRY_ENABLED = True
 # RETRY_TIMES = 2
@@ -148,11 +151,11 @@ SCHEDULER_FLUSH_ON_START = False
 # POST_PASSWORD = '123456'
 
 #以后解开这个位置的注释
-POST_HOST = '172.17.0.4'
-POST_DATABASE = 'kaiyou'
-POST_USER = 'kaiyou'
-POST_PORT = '5432'
-POST_PASSWORD = 'yjkj8888'
+# POST_HOST = '172.17.0.4'
+# POST_DATABASE = 'kaiyou'
+# POST_USER = 'kaiyou'
+# POST_PORT = '5432'
+# POST_PASSWORD = 'yjkj8888'
 
 
 # POST_HOST = '192.168.2.200'
@@ -161,8 +164,8 @@ POST_PASSWORD = 'yjkj8888'
 # POST_PORT = '10432'
 # POST_PASSWORD = '123456'
 
-R_HOST = 'localhost'
-R_POST = '6379'
+# R_HOST = 'localhost'
+# R_POST = '6379'
 # R_PASSWORD = '123456'
 #
 # POST_HOST = 'localhost'

+ 4 - 4
hg3535/spiders/bangqiu.py

@@ -15,11 +15,12 @@ class BqrangqiuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES": {
-            "hg3535.pipelines.Bangqiupipeline": 300,
+            "hg3535.pipeline.Bangqiupipeline": 300,
         },
         'LOG_LEVEL': 'DEBUG',
         'LOG_FILE': "../hg3535/log/bangqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
     }
+
     def start_requests(self):
         for y in range(1, 4):
             url = 'https://hg3535z.com/odds2/d/getodds?sid=4&pt=' + str(y) + '&ubt=am&pn=0&sb=2&dc=null&pid=0'
@@ -51,7 +52,6 @@ class BqrangqiuSpider(scrapy.Spider):
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
 
     def parse_each(self, response):
-        # print('111111111111111111111111111111111111111111111111111111111')
         try:
             new_datas = json.loads(response.text)['eg']
             # print(new_datas)
@@ -192,8 +192,8 @@ class BqrangqiuSpider(scrapy.Spider):
 
                     except:
                         odd_evens_dict['two_sides_single'] = ""
-                        odd_evens_dict['two_sides_single'] = ""
-                        odd_evens_dict_rule['two_sides_double'] = ""
+                        odd_evens_dict['two_sides_double'] = ""
+                        odd_evens_dict_rule['two_sides_single'] = ""
                         odd_evens_dict_rule['two_sides_double'] = ""
 # 球队得分大小  待采集----------------------------------------------------------------------------------------------------
 

+ 16 - 9
hg3535/spiders/bq_jieshu.py

@@ -13,12 +13,12 @@ class HgjieshuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES":{
-            'hg3535.pipelines.Bangjieshuqiupipeline': 300,
+            'hg3535.pipeline.Bangjieshuqiupipeline': 300,
         },
         'LOG_LEVEL': 'DEBUG',
         'LOG_FILE': "../hg3535/log/bq_jieshu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
     }
-    start_urls = ['https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/4/normal/1']
+    start_urls = ['https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/4/normal/1', 'https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/4/normal/2']
 
     def parse(self, response):
         if response.status == 200:
@@ -47,16 +47,23 @@ class HgjieshuSpider(scrapy.Spider):
                 except:
                     c = ""
                     temascore_list.append(c)
-            print(temaid_list)
-            print(temascore_list)
-            print(len(temaid_list))
-            print(len(temascore_list))
+            # print(temaid_list)
+            # print(temascore_list)
+            # print(len(temaid_list))
+            # print(len(temascore_list))
             # 赛事id,赛事比元组列表
             tema_tupe = {(temaid_list[i], temascore_list[i]) for i in range(len(temaid_list))}
             print(tema_tupe)
             print(len(tema_tupe))
+            # for y in tema_tupe:
+            #     if y[1]:
+            #         item = Bangjieguo()
+            #         item['id_score'] = y
+            #         yield item
+            id_list = []
+            item = Bangjieguo()
             for y in tema_tupe:
                 if y[1]:
-                    item = Bangjieguo()
-                    item['id_score'] = y
-                    yield item
+                    id_list.append(y[0])
+            item['id_score'] = id_list
+            yield item

+ 8 - 25
hg3535/spiders/guanjun.py

@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-import copy
+# import copy
 import datetime
 import json
 
@@ -15,30 +15,19 @@ class LqguanjunSpider(scrapy.Spider):
     to_day = datetime.datetime.now()
     custom_settings = {
         "ITEM_PIPELINES": {
-            'hg3535.pipelines.Guanjunpipeline': 300,
+            'hg3535.pipeline.guanjun.Guanjunpipeline': 300,
         },
-        'LOG_LEVEL': 'DEBUG',
-        'LOG_FILE': "../hg3535/log/guanjun_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
+        # 'LOG_LEVEL': 'DEBUG',
+        # 'LOG_FILE': "../hg3535/log/guanjun_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
     }
 
     def start_requests(self):
         for z in range(1, 5):
-            # for y in range(1, 4):
-            #     for x in range(0, 4):
-            #         url = 'https://hg3535z.com/odds2/d/getodds?sid=' + str(z) + '&pt=' + str(y) + '&ubt=or&pn=' + str(
-            #             x) + '&sb=2&dc=null&pid=0'
-            #         # yield Request(url=url, callback=self.parse, meta={'pt': y, 'sid': z}, dont_filter=True)
-            #         # https://hg3535z.com/odds2/d/getodds?sid=1&pt=1&ubt=am&pn=0&sb=2&dc=null&pid=0
-            #         # https://hg3535z.com/odds2/d/getodds?sid=1&pt=1&ubt=or&pn=0&sb=2&dc=null&pid=0
-            #         yield Request(url=url, callback=self.parse, meta={'pt': y, 'sid': z}, dont_filter=True)
-            # for y in range(1, 4):
             for x in range(0, 4):
-                url = 'https://hg3535z.com/odds2/d/getodds?sid=' + str(z) + '&pt=1&ubt=or&pn=' + str(
-                    x) + '&sb=2&dc=null&pid=0'
-                # yield Request(url=url, callback=self.parse, meta={'pt': y, 'sid': z}, dont_filter=True)
-                # https://hg3535z.com/odds2/d/getodds?sid=1&pt=1&ubt=am&pn=0&sb=2&dc=null&pid=0
-                # https://hg3535z.com/odds2/d/getodds?sid=1&pt=1&ubt=or&pn=0&sb=2&dc=null&pid=0
+                url = 'https://odata.jiushan6688.com/odds6i/d/getodds/zh-cn/sid/' + str(z) + '/pt/1/ubt/or/pn/' + str(
+                    x) + '/sb/2/dc/null/pid/0'
                 yield Request(url=url, callback=self.parse, meta={'pt': 1, 'sid': z}, dont_filter=True)
+
     def parse(self, response):
         try:
             datas = json.loads(response.text)
@@ -48,10 +37,6 @@ class LqguanjunSpider(scrapy.Spider):
             results = datas['n-ot']['egs']
         except:
             results = ""
-        try:
-            pt = copy.copy(response.meta['pt'])
-        except:
-            pt = 0
         try:
             ball = datas['n-ot']['s']['n']
         except:
@@ -64,11 +49,9 @@ class LqguanjunSpider(scrapy.Spider):
                 league_name = result['c']['n']
                 new_results = result['es']
                 for new_result in new_results:
-
                     data_game = new_result['i'][4]
                     time_game = new_result['i'][5]
                     new_league_name = new_result['egn'].replace('\t', '')
-
                     for i in new_result['n-o']:
                         new_champion = i['mn']
                         for y in i['o']:
@@ -85,6 +68,6 @@ class LqguanjunSpider(scrapy.Spider):
                             item['new_league_name'] = new_league_name
                             item['champion_team'] = champion_team
                             item['new_champion'] = new_champion
-                            item['pt'] = pt
+                            # item['pt'] = pt
                             item['ball'] = ball
                             yield item

+ 254 - 263
hg3535/spiders/lanqiu.py

@@ -45,17 +45,20 @@ class LanqiuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES": {
-            "hg3535.pipelines.Lanqiupipeline": 300,
+            "hg3535.pipeline.lanqiu.Lanqiupipeline": 300,
+            # 'hg3535.pipeline.zuqiu.Zuqiupipeline': 300,
         },
-        'LOG_LEVEL': 'DEBUG',
-        'LOG_FILE': "../hg3535/log/lanqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
+        # 'LOG_LEVEL': 'DEBUG',
+        # 'LOG_FILE': "../hg3535/log/lanqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
     }
 
     def start_requests(self):
         # newall_lists = ['am', 'ftht1x2', 'oe', 'tg', 'htft', 'cs', 'fglg', 'or']
         for y in range(1, 4):
-            url = 'https://hg3535z.com/odds2/d/getodds?sid=2&pt='+str(y)+'&ubt=am&pn=0&sb=2&dc=null&pid=0'
-            yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y}, dont_filter=True)
+            # url = 'https://hg3535z.com/odds2/d/getodds?sid=2&pt='+str(y)+'&ubt=am&pn=0&sb=2&dc=null&pid=0'
+            url = "https://odata.jiushan6688.com/odds6i/d/getodds/zh-cn/sid/2/pt/" + str(y) + "/ubt/am/pn/0/sb/2/dc/null/pid/0"
+            yield scrapy.Request(url=url, callback=self.parse, dont_filter=True, meta={'pt': y})
+            # yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y}, dont_filter=True)
 
     def parse(self, response):
         if response.text:
@@ -156,14 +159,14 @@ class LanqiuSpider(scrapy.Spider):
                         concedes_dict_rule['concede_guest'] = concede_guest_rule
                         concedes_dict['concede_guest'] = concede_guest
                     except:
-                        concede_guest = ""
-                        concede_guest_rule = ""
-                        concede_home = ""
-                        concede_home_rule = ""
-                        concedes_dict_rule['concede_home'] = concede_home_rule
-                        concedes_dict['concede_home'] = concede_home
-                        concedes_dict_rule['concede_guest'] = concede_guest_rule
-                        concedes_dict['concede_guest'] = concede_guest
+                        # concede_guest = ""
+                        # concede_guest_rule = ""
+                        # concede_home = ""
+                        # concede_home_rule = ""
+                        concedes_dict_rule['concede_home'] = None
+                        concedes_dict['concede_home'] = None
+                        concedes_dict_rule['concede_guest'] = None
+                        concedes_dict['concede_guest'] = None
                     # print(concedes_dict)
                     try:
                         half_concedes = result['o']["ah1st"]["v"]
@@ -175,14 +178,14 @@ class LanqiuSpider(scrapy.Spider):
                         concedes_dict['half_concede_guest'] = half_concede_guest
 
                     except:
-                        half_concede_home_rule = ""
-                        half_concede_home = ""
-                        half_concede_guest_rule = ""
-                        half_concede_guest = ""
-                        concedes_dict_rule['half_concede_home'] = half_concede_home_rule
-                        concedes_dict['half_concede_home'] = half_concede_home
-                        concedes_dict_rule['half_concede_guest'] = half_concede_guest_rule
-                        concedes_dict['half_concede_guest'] = half_concede_guest
+                        # half_concede_home_rule = ""
+                        # half_concede_home = ""
+                        # half_concede_guest_rule = ""
+                        # half_concede_guest = ""
+                        concedes_dict_rule['half_concede_home'] = None
+                        concedes_dict['half_concede_home'] = None
+                        concedes_dict_rule['half_concede_guest'] = None
+                        concedes_dict['half_concede_guest'] = None
 
                     # 第一节让球
                     try:
@@ -194,14 +197,14 @@ class LanqiuSpider(scrapy.Spider):
                         concedes_dict['one_concede_guest'] = one_concede_guest
 
                     except:
-                        one_concede_guest = ""
-                        one_concede_guest_rule = ""
-                        one_concede_home = ""
-                        one_concede_home_rule = ""
-                        concedes_dict['one_concede_home_rule'] = one_concede_home_rule
-                        concedes_dict['one_concede_home'] = one_concede_home
-                        concedes_dict['one_concede_guest_rule'] = one_concede_guest_rule
-                        concedes_dict['one_concede_guest'] = one_concede_guest
+                        # one_concede_guest = ""
+                        # one_concede_guest_rule = ""
+                        # one_concede_home = ""
+                        # one_concede_home_rule = ""
+                        concedes_dict_rule['one_concede_home'] = None
+                        concedes_dict['one_concede_home'] = None
+                        concedes_dict_rule['one_concede_guest'] = None
+                        concedes_dict['one_concede_guest'] = None
                     # 第二节让球
                     try:
                         two_concedes = result['o']["ahq2"]["v"]
@@ -211,14 +214,14 @@ class LanqiuSpider(scrapy.Spider):
                         concedes_dict_rule['two_concede_guest'] = two_concede_guest_rule
                         concedes_dict['two_concede_guest'] = two_concede_guest
                     except:
-                        two_concede_guest = ""
-                        two_concede_guest_rule = ""
-                        two_concede_home = ""
-                        two_concede_home_rule = ""
-                        concedes_dict_rule['two_concede_home'] = two_concede_home_rule
-                        concedes_dict['two_concede_home'] = two_concede_home
-                        concedes_dict_rule['two_concede_guest'] = two_concede_guest_rule
-                        concedes_dict['two_concede_guest'] = two_concede_guest
+                        # two_concede_guest = ""
+                        # two_concede_guest_rule = ""
+                        # two_concede_home = ""
+                        # two_concede_home_rule = ""
+                        concedes_dict_rule['two_concede_home'] = None
+                        concedes_dict['two_concede_home'] = None
+                        concedes_dict_rule['two_concede_guest'] = None
+                        concedes_dict['two_concede_guest'] = None
                     # 第三节让球
                     try:
                         three_concedes = result['o']["ahq3"]["v"]
@@ -229,14 +232,14 @@ class LanqiuSpider(scrapy.Spider):
                         concedes_dict['three_concede_guest'] = three_concede_guest
 
                     except:
-                        three_concede_guest = ""
-                        three_concede_guest_rule = ""
-                        three_concede_home = ""
-                        three_concede_home_rule = ""
-                        concedes_dict_rule['three_concede_home'] = three_concede_home_rule
-                        concedes_dict['three_concede_home'] = three_concede_home
-                        concedes_dict_rule['three_concede_guest'] = three_concede_guest_rule
-                        concedes_dict['three_concede_guest'] = three_concede_guest
+                        # three_concede_guest = ""
+                        # three_concede_guest_rule = ""
+                        # three_concede_home = ""
+                        # three_concede_home_rule = ""
+                        concedes_dict_rule['three_concede_home'] = None
+                        concedes_dict['three_concede_home'] = None
+                        concedes_dict_rule['three_concede_guest'] = None
+                        concedes_dict['three_concede_guest'] = None
                     # 第四节让球
                     try:
                         four_concedes = result['o']["ahq4"]["v"]
@@ -247,14 +250,14 @@ class LanqiuSpider(scrapy.Spider):
                         concedes_dict['four_concede_guest'] = four_concede_guest
 
                     except:
-                        four_concede_guest = ""
-                        four_concede_guest_rule = ""
-                        four_concede_home = ""
-                        four_concede_home_rule = ""
-                        concedes_dict_rule['four_concede_home'] = four_concede_home_rule
-                        concedes_dict['four_concede_home'] = four_concede_home
-                        concedes_dict_rule['four_concede_guest'] = four_concede_guest_rule
-                        concedes_dict['four_concede_guest'] = four_concede_guest
+                        # four_concede_guest = ""
+                        # four_concede_guest_rule = ""
+                        # four_concede_home = ""
+                        # four_concede_home_rule = ""
+                        concedes_dict_rule['four_concede_home'] = None
+                        concedes_dict['four_concede_home'] = None
+                        concedes_dict_rule['four_concede_guest'] = None
+                        concedes_dict['four_concede_guest'] = None
 # ----------------------------------------总分大小分割线 - ---------------------------------------------------------------
                     # 全场总分大小
                     try:
@@ -265,14 +268,14 @@ class LanqiuSpider(scrapy.Spider):
                         total_sizes_dict_rule["total_size_small"] = total_sizes_small_rule
                         total_sizes_dict["total_size_small"] = total_sizes_small
                     except:
-                        total_sizes_big_rule = ""
-                        total_sizes_big = ""
-                        total_sizes_small_rule = ""
-                        total_sizes_small = ""
-                        total_sizes_dict_rule["total_size_big"] = total_sizes_big_rule
-                        total_sizes_dict["total_size_big"] = total_sizes_big
-                        total_sizes_dict_rule["total_size_small"] = total_sizes_small_rule
-                        total_sizes_dict["total_size_small"] = total_sizes_small
+                        # total_sizes_big_rule = ""
+                        # total_sizes_big = ""
+                        # total_sizes_small_rule = ""
+                        # total_sizes_small = ""
+                        total_sizes_dict_rule["total_size_big"] = None
+                        total_sizes_dict["total_size_big"] = None
+                        total_sizes_dict_rule["total_size_small"] = None
+                        total_sizes_dict["total_size_small"] = None
                     # 上半场总分大小
                     try:
                         half_total_sizes = result['o']["ou1st"]["v"]
@@ -282,14 +285,14 @@ class LanqiuSpider(scrapy.Spider):
                         total_sizes_dict_rule["half_total_size_small"] = half_total_sizes_small_rule
                         total_sizes_dict["half_total_size_small"] = half_total_sizes_small
                     except:
-                        half_total_sizes_big_rule = ""
-                        half_total_sizes_big = ""
-                        half_total_sizes_small_rule = ""
-                        half_total_sizes_small = ""
-                        total_sizes_dict_rule["half_total_size_big"] = half_total_sizes_big_rule
-                        total_sizes_dict["half_total_size_big"] = half_total_sizes_big
-                        total_sizes_dict_rule["half_total_size_small"] = half_total_sizes_small_rule
-                        total_sizes_dict["half_total_size_small"] = half_total_sizes_small
+                        # half_total_sizes_big_rule = ""
+                        # half_total_sizes_big = ""
+                        # half_total_sizes_small_rule = ""
+                        # half_total_sizes_small = ""
+                        total_sizes_dict_rule["half_total_size_big"] = None
+                        total_sizes_dict["half_total_size_big"] = None
+                        total_sizes_dict_rule["half_total_size_small"] = None
+                        total_sizes_dict["half_total_size_small"] = None
                     # 第一节总分大小
                     try:
                         one_total_sizes = result['o']["ou1st"]["v"]
@@ -299,14 +302,14 @@ class LanqiuSpider(scrapy.Spider):
                         total_sizes_dict_rule["one_total_size_small"] = one_total_sizes_small_rule
                         total_sizes_dict["one_total_size_small"] = one_total_sizes_small
                     except:
-                        one_total_sizes_big_rule = ""
-                        one_total_sizes_big = ""
-                        one_total_sizes_small_rule = ""
-                        one_total_sizes_small = ""
-                        total_sizes_dict_rule["one_total_size_big"] = one_total_sizes_big_rule
-                        total_sizes_dict["one_total_size_big"] = one_total_sizes_big
-                        total_sizes_dict_rule["one_total_size_small"] = one_total_sizes_small_rule
-                        total_sizes_dict["one_total_size_small"] = one_total_sizes_small
+                        # one_total_sizes_big_rule = ""
+                        # one_total_sizes_big = ""
+                        # one_total_sizes_small_rule = ""
+                        # one_total_sizes_small = ""
+                        total_sizes_dict_rule["one_total_size_big"] = None
+                        total_sizes_dict["one_total_size_big"] = None
+                        total_sizes_dict_rule["one_total_size_small"] = None
+                        total_sizes_dict["one_total_size_small"] = None
                     # 第二节场总分大小
                     try:
                         two_total_sizes = result['o']["ou1st"]["v"]
@@ -316,14 +319,14 @@ class LanqiuSpider(scrapy.Spider):
                         total_sizes_dict_rule["two_total_size_small"] = two_total_sizes_small_rule
                         total_sizes_dict["two_total_size_small"] = two_total_sizes_small
                     except:
-                        two_total_sizes_big_rule = ""
-                        two_total_sizes_big = ""
-                        two_total_sizes_small_rule = ""
-                        two_total_sizes_small = ""
-                        total_sizes_dict_rule["two_total_size_big"] = two_total_sizes_big_rule
-                        total_sizes_dict["two_total_size_big"] = two_total_sizes_big
-                        total_sizes_dict_rule["two_total_size_small"] = two_total_sizes_small_rule
-                        total_sizes_dict["two_total_size_small"] = two_total_sizes_small
+                        # two_total_sizes_big_rule = ""
+                        # two_total_sizes_big = ""
+                        # two_total_sizes_small_rule = ""
+                        # two_total_sizes_small = ""
+                        total_sizes_dict_rule["two_total_size_big"] = None
+                        total_sizes_dict["two_total_size_big"] = None
+                        total_sizes_dict_rule["two_total_size_small"] = None
+                        total_sizes_dict["two_total_size_small"] = None
                     # 第三节总分大小
                     try:
                         three_total_sizes = result['o']["ou1st"]["v"]
@@ -333,14 +336,14 @@ class LanqiuSpider(scrapy.Spider):
                         total_sizes_dict_rule["three_total_size_small"] = three_total_sizes_small_rule
                         total_sizes_dict["three_total_size_small"] = three_total_sizes_small
                     except:
-                        three_total_sizes_big_rule = ""
-                        three_total_sizes_big = ""
-                        three_total_sizes_small_rule = ""
-                        three_total_sizes_small = ""
-                        total_sizes_dict_rule["three_total_size_big"] = three_total_sizes_big_rule
-                        total_sizes_dict["three_total_size_big"] = three_total_sizes_big
-                        total_sizes_dict_rule["three_total_size_small"] = three_total_sizes_small_rule
-                        total_sizes_dict["three_total_size_small"] = three_total_sizes_small
+                        # three_total_sizes_big_rule = ""
+                        # three_total_sizes_big = ""
+                        # three_total_sizes_small_rule = ""
+                        # three_total_sizes_small = ""
+                        total_sizes_dict_rule["three_total_size_big"] = None
+                        total_sizes_dict["three_total_size_big"] = None
+                        total_sizes_dict_rule["three_total_size_small"] = None
+                        total_sizes_dict["three_total_size_small"] = None
                     # 第四节总分大小
                     try:
                         four_total_sizes = result['o']["ou1st"]["v"]
@@ -350,99 +353,99 @@ class LanqiuSpider(scrapy.Spider):
                         total_sizes_dict_rule["four_total_size_small"] = four_total_sizes_small_rule
                         total_sizes_dict["four_total_size_small"] = four_total_sizes_small
                     except:
-                        four_total_sizes_big_rule = ""
-                        four_total_sizes_big = ""
-                        four_total_sizes_small_rule = ""
-                        four_total_sizes_small = ""
-                        total_sizes_dict_rule["four_total_size_big"] = four_total_sizes_big_rule
-                        total_sizes_dict["four_total_size_big"] = four_total_sizes_big
-                        total_sizes_dict_rule["four_total_size_small"] = four_total_sizes_small_rule
-                        total_sizes_dict["four_total_size_small"] = four_total_sizes_small
+                        # four_total_sizes_big_rule = ""
+                        # four_total_sizes_big = ""
+                        # four_total_sizes_small_rule = ""
+                        # four_total_sizes_small = ""
+                        total_sizes_dict_rule["four_total_size_big"] = None
+                        total_sizes_dict["four_total_size_big"] = None
+                        total_sizes_dict_rule["four_total_size_small"] = None
+                        total_sizes_dict["four_total_size_small"] = None
 
 # ----------------------------------------总分单双分割线------------------------------------------------------------------
                     # 全场 总分单双
                     try:
                         odd_evens = result['o']["oe"]["v"]
                         # # 全场 总分单, 全场 总分双
-                        odd_even_odd, odd_even_even = danshaung_fun(inner=odd_evens)
-                        odd_evens_dict["two_sides_single"] = odd_even_odd
+                        # odd_even_odd, odd_even_even = danshaung_fun(inner=odd_evens)
+                        odd_evens_dict["two_sides_single"] = odd_evens[1]
                         odd_evens_dict_rule['two_sides_single'] = '单'
-                        odd_evens_dict["two_sides_double"] = odd_even_even
+                        odd_evens_dict["two_sides_double"] = odd_evens[3]
                         odd_evens_dict_rule['two_sides_double'] = '双'
                     except:
-                        odd_even_odd = ""
-                        odd_even_even = ""
-                        odd_evens_dict["two_sides_single"] = odd_even_odd
+                        # odd_even_odd = ""
+                        # odd_even_even = ""
+                        odd_evens_dict["two_sides_single"] = None
                         odd_evens_dict_rule['two_sides_single'] = '单'
-                        odd_evens_dict["two_sides_double"] = odd_even_even
+                        odd_evens_dict["two_sides_double"] = None
                         odd_evens_dict_rule['two_sides_double'] = '双'
                     # 上半场全场 总分单双
 
                     try:
                         half_odd_evens = result['o']["oe1st"]["v"]
                         # 上半场 总分单, 上半场 总分双
-                        half_odd_even_odd,half_odd_even_even = danshaung_fun(inner=half_odd_evens)
-                        odd_evens_dict["two_sides_single"] = half_odd_even_odd
+                        # half_odd_even_odd,half_odd_even_even = danshaung_fun(inner=half_odd_evens)
+                        odd_evens_dict["two_sides_single"] = half_odd_evens[1]
                         odd_evens_dict_rule['two_sides_single'] = '单'
-                        odd_evens_dict["two_sides_double"] = half_odd_even_even
+                        odd_evens_dict["two_sides_double"] = half_odd_evens[3]
                         odd_evens_dict_rule['two_sides_double'] = '双'
                     except:
-                        half_odd_even_odd = ""
-                        half_odd_even_even = ""
-                        odd_evens_dict["half_two_sides_single"] = half_odd_even_odd
+                        # half_odd_even_odd = ""
+                        # half_odd_even_even = ""
+                        odd_evens_dict["half_two_sides_single"] = None
                         odd_evens_dict_rule['half_two_sides_single'] = '单'
-                        odd_evens_dict["half_two_sides_double"] = half_odd_even_even
+                        odd_evens_dict["half_two_sides_double"] = None
                         odd_evens_dict_rule['half_two_sides_double'] = '双'
 
                     # 总分:单/双-第一节
                     try:
                         one_odd_evens = result['o']["oeq1"]["v"]
-                        one_odd_even_odd,one_odd_even_even = danshaung_fun(inner=one_odd_evens)
-                        odd_evens_dict["one_two_sides_single"] = one_odd_even_odd
+                        # one_odd_even_odd,one_odd_even_even = danshaung_fun(inner=one_odd_evens)
+                        odd_evens_dict["one_two_sides_single"] = one_odd_evens[1]
                         odd_evens_dict_rule['one_two_sides_single'] = '单'
-                        odd_evens_dict["one_two_sides_double"] = one_odd_even_even
+                        odd_evens_dict["one_two_sides_double"] = one_odd_evens[3]
                         odd_evens_dict_rule['one_two_sides_double'] = '双'
                     except:
-                        one_odd_even_odd = ""
-                        one_odd_even_even = ""
-                        odd_evens_dict["one_two_sides_single"] = one_odd_even_odd
+                        # one_odd_even_odd = ""
+                        # one_odd_even_even = ""
+                        odd_evens_dict["one_two_sides_single"] = None
                         odd_evens_dict_rule['one_two_sides_single'] = '单'
-                        odd_evens_dict["one_two_sides_double"] = one_odd_even_even
+                        odd_evens_dict["one_two_sides_double"] = None
                         odd_evens_dict_rule['one_two_sides_double'] = '双'
 
 
                     # 总分:单/双-第二节
                     try:
                         two_odd_evens = result['o']["oeq2"]["v"]
-                        two_odd_even_odd,two_odd_even_even = danshaung_fun(inner=two_odd_evens)
-                        odd_evens_dict["two_two_sides_single"] = two_odd_even_odd
+                        # two_odd_even_odd,two_odd_even_even = danshaung_fun(inner=two_odd_evens)
+                        odd_evens_dict["two_two_sides_single"] = two_odd_evens[1]
                         odd_evens_dict_rule['two_two_sides_single'] = '单'
-                        odd_evens_dict["two_two_sides_double"] = two_odd_even_even
+                        odd_evens_dict["two_two_sides_double"] = two_odd_evens[3]
                         odd_evens_dict_rule['two_two_sides_double'] = '双'
                     except:
-                        two_odd_even_odd = ""
-                        two_odd_even_even = ""
-                        odd_evens_dict["two_two_sides_single"] = two_odd_even_odd
+                        # two_odd_even_odd = ""
+                        # two_odd_even_even = ""
+                        odd_evens_dict["two_two_sides_single"] = None
                         odd_evens_dict_rule['two_two_sides_single'] = '单'
-                        odd_evens_dict["two_two_sides_double"] = two_odd_even_even
+                        odd_evens_dict["two_two_sides_double"] = None
                         odd_evens_dict_rule['two_two_sides_double'] = '双'
 
                     # 总分:单/双-第三节
                     try:
                         three_odd_evens = result['o']["oeq3"]["v"]
-                        three_odd_even_odd,three_odd_even_even = danshaung_fun(inner=three_odd_evens)
-                        odd_evens_dict["three_two_sides_single"] = three_odd_even_odd
+                        # three_odd_even_odd,three_odd_even_even = danshaung_fun(inner=three_odd_evens)
+                        odd_evens_dict["three_two_sides_single"] = three_odd_evens[1]
                         odd_evens_dict_rule['three_two_sides_single'] = '单'
-                        odd_evens_dict["three_two_sides_double"] = three_odd_even_even
+                        odd_evens_dict["three_two_sides_double"] = three_odd_evens[3]
                         odd_evens_dict_rule['three_two_sides_double'] = '双'
 
 
                     except:
-                        three_odd_even_odd = ""
-                        three_odd_even_even = ""
-                        odd_evens_dict["three_two_sides_single"] = three_odd_even_odd
+                        # three_odd_even_odd = ""
+                        # three_odd_even_even = ""
+                        odd_evens_dict["three_two_sides_single"] = None
                         odd_evens_dict_rule['three_two_sides_single'] = '单'
-                        odd_evens_dict["three_two_sides_double"] = three_odd_even_even
+                        odd_evens_dict["three_two_sides_double"] = None
                         odd_evens_dict_rule['three_two_sides_double'] = '双'
 
 
@@ -450,17 +453,17 @@ class LanqiuSpider(scrapy.Spider):
                     # 总分:单/双-第四节
                     try:
                         four_odd_evens = result['o']["oeq4"]["v"]
-                        four_odd_even_odd,four_odd_even_even = danshaung_fun(inner=four_odd_evens)
-                        odd_evens_dict["four_two_sides_single"] = four_odd_even_odd
+                        # four_odd_even_odd,four_odd_even_even = danshaung_fun(inner=four_odd_evens)
+                        odd_evens_dict["four_two_sides_single"] = four_odd_evens[1]
                         odd_evens_dict_rule['four_two_sides_single'] = '单'
-                        odd_evens_dict["four_two_sides_double"] = four_odd_even_even
+                        odd_evens_dict["four_two_sides_double"] = four_odd_evens[3]
                         odd_evens_dict_rule['four_two_sides_double'] = '双'
                     except:
-                        four_odd_even_odd = ""
-                        four_odd_even_even = ""
-                        odd_evens_dict["four_two_sides_single"] = four_odd_even_odd
+                        # four_odd_even_odd = ""
+                        # four_odd_even_even = ""
+                        odd_evens_dict["four_two_sides_single"] = None
                         odd_evens_dict_rule['four_two_sides_single'] = '单'
-                        odd_evens_dict["four_two_sides_double"] = four_odd_even_even
+                        odd_evens_dict["four_two_sides_double"] = None
                         odd_evens_dict_rule['four_two_sides_double'] = '双'
 
 # ----------------------------------------球队得分最后一位数分割线---------------------------------------------------------
@@ -500,10 +503,10 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["capot_home"] = capot_home
                         capots_dict["capot_guest"] = capot_guest
                     except:
-                        capot_home = ""
-                        capot_guest = ""
-                        capots_dict["capot_home"] = capot_home
-                        capots_dict["capot_guest"] = capot_guest
+                        # capot_home = ""
+                        # capot_guest = ""
+                        capots_dict["capot_home"] = None
+                        capots_dict["capot_guest"] = None
 
                     # 上半场独赢
                     try:
@@ -514,10 +517,10 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["half_capot_home"] = half_capot_home
                         capots_dict["half_capot_guest"] = half_capot_guest
                     except:
-                        half_capot_home = ""
-                        half_capot_guest = ""
-                        capots_dict["half_capot_home"] = half_capot_home
-                        capots_dict["half_capot_guest"] = half_capot_guest
+                        # half_capot_home = ""
+                        # half_capot_guest = ""
+                        capots_dict["half_capot_home"] = None
+                        capots_dict["half_capot_guest"] = None
 
                     # 第一节独赢
                     try:
@@ -528,10 +531,10 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["one_capot_home"] = one_capot_home
                         capots_dict["one_capot_guest"] = one_capot_guest
                     except:
-                        one_capot_home = ""
-                        one_capot_guest = ""
-                        capots_dict["one_capot_home"] = one_capot_home
-                        capots_dict["one_capot_guest"] = one_capot_guest
+                        # one_capot_home = ""
+                        # one_capot_guest = ""
+                        capots_dict["one_capot_home"] = None
+                        capots_dict["one_capot_guest"] = None
 
                     # 第二节独赢
                     try:
@@ -542,10 +545,10 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["two_capot_home"] = two_capot_home
                         capots_dict["two_capot_guest"] = two_capot_guest
                     except:
-                        two_capot_home = ""
-                        two_capot_guest = ""
-                        capots_dict["two_capot_home"] = two_capot_home
-                        capots_dict["two_capot_guest"] = two_capot_guest
+                        # two_capot_home = ""
+                        # two_capot_guest = ""
+                        capots_dict["two_capot_home"] = None
+                        capots_dict["two_capot_guest"] = None
 
                     # 第三节独赢
                     try:
@@ -556,10 +559,10 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["three_capot_home"] = three_capot_home
                         capots_dict["three_capot_guest"] = three_capot_guest
                     except:
-                        three_capot_home = ""
-                        three_capot_guest = ""
-                        capots_dict["three_capot_home"] = three_capot_home
-                        capots_dict["three_capot_guest"] = three_capot_guest
+                        # three_capot_home = ""
+                        # three_capot_guest = ""
+                        capots_dict["three_capot_home"] = None
+                        capots_dict["three_capot_guest"] = None
 
                     # 第四节独赢
                     try:
@@ -570,10 +573,10 @@ class LanqiuSpider(scrapy.Spider):
                         capots_dict["four_capot_home"] = four_capot_home
                         capots_dict["four_capot_guest"] = four_capot_guest
                     except:
-                        four_capot_home = ""
-                        four_capot_guest = ""
-                        capots_dict["four_capot_home"] = four_capot_home
-                        capots_dict["four_capot_guest"] = four_capot_guest
+                        # four_capot_home = ""
+                        # four_capot_guest = ""
+                        capots_dict["four_capot_home"] = None
+                        capots_dict["four_capot_guest"] = None
 
 # ---------------------------------------------------华丽分割线列表es[1]--------------------------------------------------
             # 球队得分 全场主队 home
@@ -592,14 +595,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["score_home_small"] = score_home_small_rule
                             team_scores_dict["score_home_small"] = score_home_small
                         except:
-                            score_home_small = ""
-                            score_home_small_rule = ""
-                            score_home_big_rule = ""
-                            score_home_big = ""
-                            team_scores_dict_rule["score_home_big"] = score_home_big_rule
-                            team_scores_dict["score_home_big"] = score_home_big
-                            team_scores_dict_rule["score_home_small"] = score_home_small_rule
-                            team_scores_dict["score_home_small"] = score_home_small
+                            # score_home_small = ""
+                            # score_home_small_rule = ""
+                            # score_home_big_rule = ""
+                            # score_home_big = ""
+                            team_scores_dict_rule["score_home_big"] = None
+                            team_scores_dict["score_home_big"] = None
+                            team_scores_dict_rule["score_home_small"] = None
+                            team_scores_dict["score_home_small"] = None
                         # 球队得分 上半场主队 home
                         try:
                             half_score_homes = score_home['o']['ou1st']['v']
@@ -610,14 +613,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["half_score_home_small"] = half_score_home_small_rule
                             team_scores_dict["half_score_home_small"] = half_score_home_small
                         except:
-                            half_score_home_small = ""
-                            half_score_home_small_rule = ""
-                            half_score_home_big = ""
-                            half_score_home_big_rule = ""
-                            team_scores_dict_rule["half_score_home_big"] = half_score_home_big_rule
-                            team_scores_dict["half_score_home_big"] = half_score_home_big
-                            team_scores_dict_rule["half_score_home_small"] = half_score_home_small_rule
-                            team_scores_dict["half_score_home_small"] = half_score_home_small
+                            # half_score_home_small = ""
+                            # half_score_home_small_rule = ""
+                            # half_score_home_big = ""
+                            # half_score_home_big_rule = ""
+                            team_scores_dict_rule["half_score_home_big"] = None
+                            team_scores_dict["half_score_home_big"] = None
+                            team_scores_dict_rule["half_score_home_small"] = None
+                            team_scores_dict["half_score_home_small"] = None
 
                         # 球队得分:主队-大 / 小-第一节
                         try:
@@ -628,14 +631,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["one_score_home_small"] = one_score_home_small_rule
                             team_scores_dict["one_score_home_small"] = one_score_home_small
                         except:
-                            one_score_home_small = ""
-                            one_score_home_small_rule = ""
-                            one_score_home_big = ""
-                            one_score_home_big_rule = ""
-                            team_scores_dict_rule["one_score_home_big"] = one_score_home_big_rule
-                            team_scores_dict["one_score_home_big"] = one_score_home_big
-                            team_scores_dict_rule["one_score_home_small"] = one_score_home_small_rule
-                            team_scores_dict["one_score_home_small"] = one_score_home_small
+                            # one_score_home_small = ""
+                            # one_score_home_small_rule = ""
+                            # one_score_home_big = ""
+                            # one_score_home_big_rule = ""
+                            team_scores_dict_rule["one_score_home_big"] = None
+                            team_scores_dict["one_score_home_big"] = None
+                            team_scores_dict_rule["one_score_home_small"] = None
+                            team_scores_dict["one_score_home_small"] = None
 
                         # 球队得分:主队-大 / 小-第一节
                         try:
@@ -646,14 +649,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["two_score_home_small"] = two_score_home_small_rule
                             team_scores_dict["two_score_home_small"] = two_score_home_small
                         except:
-                            two_score_home_small = ""
-                            two_score_home_small_rule = ""
-                            two_score_home_big = ""
-                            two_score_home_big_rule = ""
-                            team_scores_dict_rule["two_score_home_big"] = two_score_home_big_rule
-                            team_scores_dict["two_score_home_big"] = two_score_home_big
-                            team_scores_dict_rule["two_score_home_small"] = two_score_home_small_rule
-                            team_scores_dict["two_score_home_small"] = two_score_home_small
+                            # two_score_home_small = ""
+                            # two_score_home_small_rule = ""
+                            # two_score_home_big = ""
+                            # two_score_home_big_rule = ""
+                            team_scores_dict_rule["two_score_home_big"] = None
+                            team_scores_dict["two_score_home_big"] = None
+                            team_scores_dict_rule["two_score_home_small"] = None
+                            team_scores_dict["two_score_home_small"] = None
 
                         # 球队得分:主队-大 / 小-第一节
                         try:
@@ -664,14 +667,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["three_score_home_small"] = three_score_home_small_rule
                             team_scores_dict["three_score_home_small"] = three_score_home_small
                         except:
-                            three_score_home_small = ""
-                            three_score_home_small_rule = ""
-                            three_score_home_big = ""
-                            three_score_home_big_rule = ""
-                            team_scores_dict_rule["three_score_home_big"] = three_score_home_big_rule
-                            team_scores_dict["three_score_home_big"] = three_score_home_big
-                            team_scores_dict_rule["three_score_home_small"] = three_score_home_small_rule
-                            team_scores_dict["three_score_home_small"] = three_score_home_small
+                            # three_score_home_small = ""
+                            # three_score_home_small_rule = ""
+                            # three_score_home_big = ""
+                            # three_score_home_big_rule = ""
+                            team_scores_dict_rule["three_score_home_big"] = None
+                            team_scores_dict["three_score_home_big"] = None
+                            team_scores_dict_rule["three_score_home_small"] = None
+                            team_scores_dict["three_score_home_small"] = None
 
                         # 球队得分:主队-大 / 小-第四节
                         try:
@@ -682,14 +685,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["four_score_home_small"] = four_score_home_small_rule
                             team_scores_dict["four_score_home_small"] = four_score_home_small
                         except:
-                            four_score_home_small = ""
-                            four_score_home_small_rule = ""
-                            four_score_home_big = ""
-                            four_score_home_big_rule = ""
-                            team_scores_dict_rule["four_score_home_big"] = four_score_home_big_rule
-                            team_scores_dict["four_score_home_big"] = four_score_home_big
-                            team_scores_dict_rule["four_score_home_small"] = four_score_home_small_rule
-                            team_scores_dict["four_score_home_small"] = four_score_home_small
+                            # four_score_home_small = ""
+                            # four_score_home_small_rule = ""
+                            # four_score_home_big = ""
+                            # four_score_home_big_rule = ""
+                            team_scores_dict_rule["four_score_home_big"] = None
+                            team_scores_dict["four_score_home_big"] = None
+                            team_scores_dict_rule["four_score_home_small"] = None
+                            team_scores_dict["four_score_home_small"] = None
 
 
 # ---------------------------------------------------华丽分割线列表es[2]--------------------------------------------------
@@ -709,14 +712,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["score_guest_small"] = score_guest_small_rule
                             team_scores_dict["score_guest_small"] = score_guest_small
                         except:
-                            score_guest_small = ""
-                            score_guest_small_rule = ""
-                            score_guest_big = ""
-                            score_guest_big_rule = ""
-                            team_scores_dict_rule["score_guest_big"] = score_guest_big_rule
-                            team_scores_dict["score_guest_big"] = score_guest_big
-                            team_scores_dict_rule["score_guest_small"] = score_guest_small_rule
-                            team_scores_dict["score_guest_small"] = score_guest_small
+                            # score_guest_small = None
+                            # score_guest_small_rule = None
+                            # score_guest_big = None
+                            # score_guest_big_rule = None
+                            team_scores_dict_rule["score_guest_big"] = None
+                            team_scores_dict["score_guest_big"] = None
+                            team_scores_dict_rule["score_guest_small"] = None
+                            team_scores_dict["score_guest_small"] = None
 
                         # 球队得分 上半场客队 guest
                         try:
@@ -727,14 +730,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["half_score_guest_small"] = half_score_guest_small_rule
                             team_scores_dict["half_score_guest_small"] = half_score_guest_small
                         except:
-                            half_score_guest_small = ""
-                            half_score_guest_small_rule = ""
-                            half_score_guest_big = ""
-                            half_score_guest_big_rule = ""
-                            team_scores_dict_rule["half_score_guest_big"] = half_score_guest_big_rule
-                            team_scores_dict["half_score_guest_big"] = half_score_guest_big
-                            team_scores_dict_rule["half_score_guest_small"] = half_score_guest_small_rule
-                            team_scores_dict["half_score_guest_small"] = half_score_guest_small
+                            # half_score_guest_small = None
+                            # half_score_guest_small_rule = None
+                            # half_score_guest_big = None
+                            # half_score_guest_big_rule = None
+                            team_scores_dict_rule["half_score_guest_big"] = None
+                            team_scores_dict["half_score_guest_big"] = None
+                            team_scores_dict_rule["half_score_guest_small"] = None
+                            team_scores_dict["half_score_guest_small"] = None
                         # 球队得分第一节
                         try:
                             one_score_guests = score_guest["o"]['ouq1']['v']
@@ -745,14 +748,14 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["one_score_guest_small"] = one_score_guest_small_rule
                             team_scores_dict["one_score_guest_small"] = one_score_guest_small
                         except:
-                            one_score_guest_small = ""
-                            one_score_guest_small_rule = ""
-                            one_score_guest_big = ""
-                            one_score_guest_big_rule = ""
-                            team_scores_dict_rule["one_score_guest_big"] = one_score_guest_big_rule
-                            team_scores_dict["one_score_guest_big"] = one_score_guest_big
-                            team_scores_dict_rule["one_score_guest_small"] = one_score_guest_small_rule
-                            team_scores_dict["one_score_guest_small"] = one_score_guest_small
+                            # one_score_guest_small = None
+                            # one_score_guest_small_rule = None
+                            # one_score_guest_big = None
+                            # one_score_guest_big_rule = None
+                            team_scores_dict_rule["one_score_guest_big"] = None
+                            team_scores_dict["one_score_guest_big"] = None
+                            team_scores_dict_rule["one_score_guest_small"] = None
+                            team_scores_dict["one_score_guest_small"] = None
 
                         # 球队得分第二节
                         try:
@@ -764,14 +767,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["two_score_guest_small"] = two_score_guest_small_rule
                             team_scores_dict["two_score_guest_small"] = two_score_guest_small
                         except:
-                            two_score_guest_small = ""
-                            two_score_guest_small_rule = ""
-                            two_score_guest_big = ""
-                            two_score_guest_big_rule = ""
-                            team_scores_dict_rule["two_score_guest_big"] = two_score_guest_big_rule
-                            team_scores_dict["two_score_guest_big"] = two_score_guest_big
-                            team_scores_dict_rule["lq_two_score_guest_small"] = two_score_guest_small_rule
-                            team_scores_dict["two_score_guest_small"] = two_score_guest_small
+                            team_scores_dict_rule["two_score_guest_big"] = None
+                            team_scores_dict["two_score_guest_big"] = None
+                            team_scores_dict_rule["two_score_guest_small"] = None
+                            team_scores_dict["two_score_guest_small"] = None
                         # 球队得分第三节
                         try:
                             three_score_guests = score_guest["o"]['ouq3']['v']
@@ -782,14 +781,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["three_score_guest_small"] = three_score_guest_small_rule
                             team_scores_dict["three_score_guest_small"] = three_score_guest_small
                         except:
-                            three_score_guest_small = ""
-                            three_score_guest_small_rule = ""
-                            three_score_guest_big = ""
-                            three_score_guest_big_rule = ""
-                            team_scores_dict_rule["three_score_guest_big"] = three_score_guest_big_rule
-                            team_scores_dict["three_score_guest_big"] = three_score_guest_big
-                            team_scores_dict_rule["three_score_guest_small"] = three_score_guest_small_rule
-                            team_scores_dict["three_score_guest_small"] = three_score_guest_small
+                            team_scores_dict_rule["three_score_guest_big"] = None
+                            team_scores_dict["three_score_guest_big"] = None
+                            team_scores_dict_rule["three_score_guest_small"] = None
+                            team_scores_dict["three_score_guest_small"] = None
                         # 球队得分第四节
                         try:
                             four_score_guests = score_guest["o"]['ouq4']['v']
@@ -800,14 +795,10 @@ class LanqiuSpider(scrapy.Spider):
                             team_scores_dict_rule["four_score_guest_small"] = four_score_guest_small_rule
                             team_scores_dict["four_score_guest_small"] = four_score_guest_small
                         except:
-                            four_score_guest_small = ""
-                            four_score_guest_small_rule = ""
-                            four_score_guest_big = ""
-                            four_score_guest_big_rule = ""
-                            team_scores_dict_rule["four_score_guest_big"] = four_score_guest_big_rule
-                            team_scores_dict["four_score_guest_big"] = four_score_guest_big
-                            team_scores_dict_rule["four_score_guest_small"] = four_score_guest_small_rule
-                            team_scores_dict["four_score_guest_small"] = four_score_guest_small
+                            team_scores_dict_rule["four_score_guest_big"] = None
+                            team_scores_dict["four_score_guest_big"] = None
+                            team_scores_dict_rule["four_score_guest_small"] = None
+                            team_scores_dict["four_score_guest_small"] = None
 
             # 联赛id
             item['league_id'] = league_id

+ 7 - 5
hg3535/spiders/liansai.py

@@ -16,17 +16,19 @@ class LanqiulsSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES": {
-            'hg3535.pipelines.Liansaipipeline': 300,
+            'hg3535.pipeline.Liansaipipeline': 300,
         },
-        'LOG_LEVEL': 'DEBUG',
-        'LOG_FILE': "../hg3535/log/liansai_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
+        # 'LOG_LEVEL': 'DEBUG',
+        # 'LOG_FILE': "../hg3535/log/liansai_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
     }
 
     def start_requests(self):
+        gj_list = ['am', 'or']
         for y in range(1, 5):
             for i in range(1, 5):
-                url = 'https://hg3535z.com/odds2/d/getcomps?sid='+str(y)+'&pt=' + str(i) + '&ubt=am&dc=null&pn=0&pid=0'
-                yield scrapy.Request(url=url, callback=self.parse, dont_filter=True)
+                for z in gj_list:
+                    url = 'https://hg3535z.com/odds2/d/getcomps?sid='+str(y)+'&pt=' + str(i) + '&ubt=' + z +'&dc=null&pn=0&pid=0'
+                    yield scrapy.Request(url=url, callback=self.parse, dont_filter=True)
                 # yield scrapy.Request(url=url, callback=self.parse)
     def parse(self, response):
         try:

+ 13 - 6
hg3535/spiders/lq_jieshu.py

@@ -13,7 +13,7 @@ class HgjieshuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES":{
-            'hg3535.pipelines.Lanjieshuqiupipeline': 300,
+            'hg3535.pipeline.Lanjieshuqiupipeline': 300,
         },
         'LOG_LEVEL': 'DEBUG',
         'LOG_FILE': "../hg3535/log/lq_jieshu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
@@ -55,10 +55,17 @@ class HgjieshuSpider(scrapy.Spider):
             # 赛事id,赛事比元组列表
             tema_tupe = {(temaid_list[i], temascore_list[i]) for i in range(len(temaid_list))}
             print(tema_tupe)
-            # print(len(tema_tupe))
+            # # print(len(tema_tupe))
+            # for y in tema_tupe:
+            #     if y[1]:
+            #         item = Lanjieguo()
+            #         item['id_score'] = y
+            #         yield item
+
+            id_list = []
+            item = Lanjieguo()
             for y in tema_tupe:
                 if y[1]:
-                    item = Lanjieguo()
-                    item['id_score'] = y
-                    yield item
-
+                    id_list.append(y[0])
+            item['id_score'] = id_list
+            yield item

File diff suppressed because it is too large
+ 5 - 1
hg3535/spiders/roll_bangqiu.py


+ 141 - 205
hg3535/spiders/roll_lanqiu.py

@@ -1,8 +1,7 @@
 # -*- coding: utf-8 -*-
 import datetime
 import json
-
-import jsonpath
+# import jsonpath
 import scrapy
 from scrapy.http import Request
 
@@ -38,36 +37,36 @@ class LanqiuSpider(scrapy.Spider):
     name = "roll_lanqiu"
     to_day = datetime.datetime.now()
     allowed_domains = ['hg3535z.com']
-    start_urls = ['https://hg3535z.com/odds2/d/getodds?sid=2&pt=4&ubt=am&pn=0&sb=2&dc=null&pid=0'] # 滚球菜单 篮球滚球列url
+    start_urls = ['https://odata.jiushan6688.com/odds6i/d/getodds/zh-cn/sid/2/pt/4/ubt/am/pn/0/sb/2/dc/null/pid/0']
+    #
+    # https://odata.jiushan6688.com/odds6i/d/getodds/zh-cn/sid/2/pt/4/ubt/am/pn/0/sb/2/dc/null/pid/0
     custom_settings = {
         "ITEM_PIPELINES": {
-            "hg3535.pipelines.Roll_Lanqiupipeline": 200,
+            "hg3535.pipeline.roll_lanqiu.Roll_Lanqiupipeline": 200,
         },
         # 'LOG_LEVEL': 'DEBUG',
         # 'LOG_FILE': "../hg3535/log/roll_lanqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
     }
-    # start_urls = ['http://hg3535z.com/odds2/d/getodds?sid=2&pt=3&ubt=am&pn=0&sb=2&dc=null&pid=0']
-    # http: // hg3535z.com / odds2 / d / getamodds?eid = 3098030 & iip = false & ubt = am & isp = false
-    # http://hg3535z.com/odds2/d/getodds?sid=2&pt=2&ubt=am&pn=0&sb=2&dc=null&pid=0
 
     def parse(self, response):
-        datas = json.loads(response.text)
-        # item = Today_all()
-        ids = jsonpath.jsonpath(datas, '$..i-ot[0]..egs..es..i[16]') # ids新列表
-        print(ids)
-        if ids:
-            ids = set(ids)
-            for i in ids:
-                urls = 'https://hg3535z.com/odds2/d/getamodds?eid={}&iip=true&ubt=am&isp=false'.format(i)
-                print(urls)
-                yield Request(url=urls, callback=self.parse_other, dont_filter=True)
+        responses = json.loads(response.text)
+        try:
+            datas = responses["i-ot"]
+        except:
+            print("暂无滚球篮球数据")
+            return
+        if datas:
+            for data in datas:
+                egs = data['egs']
+                for es in egs:
+                    es = es['es']
+                    for e in es:
+                        match_id = str(e['i'][16])
+                        url = 'https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/true/ubt/am/isp/false'.format(match_id)
+                        yield Request(url=url, callback=self.parse_other, dont_filter=True)
 
     def parse_other(self,response):
         new_datas = json.loads(response.text).get('eg', "")
-        try:
-            pt = response.meta['pt']
-        except:
-            pt = 0
         item = Roll_Lanqiu()
         if new_datas:
             # 联赛id
@@ -112,10 +111,10 @@ class LanqiuSpider(scrapy.Spider):
                 concedes_dict_rule['concede_guest'] = concede_guest_rule
                 concedes_dict['concede_guest'] = concede_guest
             except:
-                concedes_dict_rule['concede_home'] = None
-                concedes_dict['concede_home'] = None
-                concedes_dict_rule['concede_guest'] = None
-                concedes_dict['concede_guest'] = None
+                concedes_dict_rule['concede_home'] = ""
+                concedes_dict['concede_home'] = ""
+                concedes_dict_rule['concede_guest'] = ""
+                concedes_dict['concede_guest'] = ""
             # print(concedes_dict)
             try:
                 half_concedes = result['o']["ah1st"]["v"]
@@ -127,10 +126,10 @@ class LanqiuSpider(scrapy.Spider):
                 concedes_dict['half_concede_guest'] = half_concede_guest
 
             except:
-                concedes_dict_rule['half_concede_home'] = None
-                concedes_dict['half_concede_home'] = None
-                concedes_dict_rule['half_concede_guest'] = None
-                concedes_dict['half_concede_guest'] = None
+                concedes_dict_rule['half_concede_home'] = ""
+                concedes_dict['half_concede_home'] = ""
+                concedes_dict_rule['half_concede_guest'] = ""
+                concedes_dict['half_concede_guest'] = ""
 
             # 第一节让球
             try:
@@ -142,10 +141,10 @@ class LanqiuSpider(scrapy.Spider):
                 concedes_dict['one_concede_guest'] = one_concede_guest
 
             except:
-                concedes_dict_rule['one_concede_home'] = None
-                concedes_dict['one_concede_home'] = None
-                concedes_dict_rule['one_concede_guest'] = None
-                concedes_dict['one_concede_guest'] = None
+                concedes_dict_rule['one_concede_home'] = ""
+                concedes_dict['one_concede_home'] = ""
+                concedes_dict_rule['one_concede_guest'] = ""
+                concedes_dict['one_concede_guest'] = ""
             # 第二节让球
             try:
                 two_concedes = result['o']["ahq2"]["v"]
@@ -155,10 +154,10 @@ class LanqiuSpider(scrapy.Spider):
                 concedes_dict_rule['two_concede_guest'] = two_concede_guest_rule
                 concedes_dict['two_concede_guest'] = two_concede_guest
             except:
-                concedes_dict_rule['two_concede_home'] = None
-                concedes_dict['two_concede_home'] = None
-                concedes_dict_rule['two_concede_guest'] = None
-                concedes_dict['two_concede_guest'] = None
+                concedes_dict_rule['two_concede_home'] = ""
+                concedes_dict['two_concede_home'] = ""
+                concedes_dict_rule['two_concede_guest'] = ""
+                concedes_dict['two_concede_guest'] = ""
             # 第三节让球
             try:
                 three_concedes = result['o']["ahq3"]["v"]
@@ -169,10 +168,10 @@ class LanqiuSpider(scrapy.Spider):
                 concedes_dict['three_concede_guest'] = three_concede_guest
 
             except:
-                concedes_dict_rule['three_concede_home'] = None
-                concedes_dict['three_concede_home'] = None
-                concedes_dict_rule['three_concede_guest'] = None
-                concedes_dict['three_concede_guest'] = None
+                concedes_dict_rule['three_concede_home'] = ""
+                concedes_dict['three_concede_home'] = ""
+                concedes_dict_rule['three_concede_guest'] = ""
+                concedes_dict['three_concede_guest'] = ""
             # 第四节让球
             try:
                 four_concedes = result['o']["ahq4"]["v"]
@@ -183,10 +182,10 @@ class LanqiuSpider(scrapy.Spider):
                 concedes_dict['four_concede_guest'] = four_concede_guest
 
             except:
-                concedes_dict_rule['four_concede_home'] = None
-                concedes_dict['four_concede_home'] = None
-                concedes_dict_rule['four_concede_guest'] = None
-                concedes_dict['four_concede_guest'] = None
+                concedes_dict_rule['four_concede_home'] = ""
+                concedes_dict['four_concede_home'] = ""
+                concedes_dict_rule['four_concede_guest'] = ""
+                concedes_dict['four_concede_guest'] = ""
 # ----------------------------------------总分大小分割线 - ---------------------------------------------------------------
             # 全场总分大小
             total_sizes_dict = {}
@@ -199,10 +198,10 @@ class LanqiuSpider(scrapy.Spider):
                 total_sizes_dict_rule["total_sizes_small"] = total_sizes_small_rule
                 total_sizes_dict["total_sizes_small"] = total_sizes_small
             except:
-                total_sizes_dict_rule["total_sizes_big"] = None
-                total_sizes_dict["total_sizes_big"] = None
-                total_sizes_dict_rule["total_sizes_small"] = None
-                total_sizes_dict["total_sizes_small"] = None
+                total_sizes_dict_rule["total_sizes_big"] = ""
+                total_sizes_dict["total_sizes_big"] = ""
+                total_sizes_dict_rule["total_sizes_small"] = ""
+                total_sizes_dict["total_sizes_small"] = ""
             # 上半场总分大小
             try:
                 half_total_sizes = result['o']["ou1st"]["v"]
@@ -212,10 +211,10 @@ class LanqiuSpider(scrapy.Spider):
                 total_sizes_dict_rule["half_total_sizes_small"] = half_total_sizes_small_rule
                 total_sizes_dict["half_total_sizes_small"] = half_total_sizes_small
             except:
-                total_sizes_dict_rule["half_total_sizes_big"] = None
-                total_sizes_dict["half_total_sizes_big"] = None
-                total_sizes_dict_rule["half_total_sizes_small"] = None
-                total_sizes_dict["half_total_sizes_small"] = None
+                total_sizes_dict_rule["half_total_sizes_big"] = ""
+                total_sizes_dict["half_total_sizes_big"] = ""
+                total_sizes_dict_rule["half_total_sizes_small"] = ""
+                total_sizes_dict["half_total_sizes_small"] = ""
             # 第一节总分大小
             try:
                 one_total_sizes = result['o']["ou1st"]["v"]
@@ -225,10 +224,10 @@ class LanqiuSpider(scrapy.Spider):
                 total_sizes_dict_rule["one_total_sizes_small"] = one_total_sizes_small_rule
                 total_sizes_dict["one_total_sizes_small"] = one_total_sizes_small
             except:
-                total_sizes_dict_rule["one_total_sizes_big"] = None
-                total_sizes_dict["one_total_sizes_big"] = None
-                total_sizes_dict_rule["one_total_sizes_small"] = None
-                total_sizes_dict["one_total_sizes_small"] = None
+                total_sizes_dict_rule["one_total_sizes_big"] = ""
+                total_sizes_dict["one_total_sizes_big"] = ""
+                total_sizes_dict_rule["one_total_sizes_small"] = ""
+                total_sizes_dict["one_total_sizes_small"] = ""
             # 第二节场总分大小
             try:
                 two_total_sizes = result['o']["ou2st"]["v"]
@@ -238,10 +237,10 @@ class LanqiuSpider(scrapy.Spider):
                 total_sizes_dict_rule["two_total_sizes_small"] = two_total_sizes_small_rule
                 total_sizes_dict["two_total_sizes_small"] = two_total_sizes_small
             except:
-                total_sizes_dict_rule["two_total_sizes_big"] = None
-                total_sizes_dict["two_total_sizes_big"] = None
-                total_sizes_dict_rule["two_total_sizes_small"] = None
-                total_sizes_dict["two_total_sizes_small"] = None
+                total_sizes_dict_rule["two_total_sizes_big"] = ""
+                total_sizes_dict["two_total_sizes_big"] = ""
+                total_sizes_dict_rule["two_total_sizes_small"] = ""
+                total_sizes_dict["two_total_sizes_small"] = ""
             # 第三节总分大小
             try:
                 three_total_sizes = result['o']["ou3st"]["v"]
@@ -251,10 +250,10 @@ class LanqiuSpider(scrapy.Spider):
                 total_sizes_dict_rule["three_total_sizes_small"] = three_total_sizes_small_rule
                 total_sizes_dict["three_total_sizes_small"] = three_total_sizes_small
             except:
-                total_sizes_dict_rule["three_total_sizes_big"] = None
-                total_sizes_dict["three_total_sizes_big"] = None
-                total_sizes_dict_rule["three_total_sizes_small"] = None
-                total_sizes_dict["three_total_sizes_small"] = None
+                total_sizes_dict_rule["three_total_sizes_big"] = ""
+                total_sizes_dict["three_total_sizes_big"] = ""
+                total_sizes_dict_rule["three_total_sizes_small"] = ""
+                total_sizes_dict["three_total_sizes_small"] = ""
             # 第四节总分大小
             try:
                 four_total_sizes = result['o']["ou4st"]["v"]
@@ -264,10 +263,10 @@ class LanqiuSpider(scrapy.Spider):
                 total_sizes_dict_rule["four_total_sizes_small"] = four_total_sizes_small_rule
                 total_sizes_dict["four_total_sizes_small"] = four_total_sizes_small
             except:
-                total_sizes_dict_rule["four_total_sizes_big"] = None
-                total_sizes_dict["four_total_sizes_big"] = None
-                total_sizes_dict_rule["four_total_sizes_small"] = None
-                total_sizes_dict["four_total_sizes_small"] = None
+                total_sizes_dict_rule["four_total_sizes_big"] = ""
+                total_sizes_dict["four_total_sizes_big"] = ""
+                total_sizes_dict_rule["four_total_sizes_small"] = ""
+                total_sizes_dict["four_total_sizes_small"] = ""
 
 # ----------------------------------------总分单双分割线------------------------------------------------------------------
             # 全场 总分单双
@@ -275,25 +274,21 @@ class LanqiuSpider(scrapy.Spider):
             odd_evens_dict_rule = {}
             try:
                 odd_evens = result['o']["oe"]["v"]
-                # # 全场 总分单, 全场 总分双
-                # odd_even_odd, odd_even_even = danshaung_fun(inner=odd_evens)
+                # 全场 总分单, 全场 总分双
                 odd_evens_dict["two_sides_single"] = odd_evens[1]
                 odd_evens_dict_rule['two_sides_single'] = '单'
                 odd_evens_dict["two_sides_double"] = odd_evens[3]
                 odd_evens_dict_rule['two_sides_double'] = '双'
             except:
-                # odd_even_odd = ""
-                # odd_even_even = ""
-                odd_evens_dict["two_sides_single"] = None
+                odd_evens_dict["two_sides_single"] = ""
                 odd_evens_dict_rule['two_sides_single'] = '单'
-                odd_evens_dict["two_sides_double"] = None
+                odd_evens_dict["two_sides_double"] = ""
                 odd_evens_dict_rule['two_sides_double'] = '双'
             # 上半场全场 总分单双
 
             try:
                 half_odd_evens = result['o']["oe1st"]["v"]
                 # 上半场 总分单, 上半场 总分双
-                # half_odd_even_odd,half_odd_even_even = danshaung_fun(inner=half_odd_evens)
                 odd_evens_dict["half_two_sides_single"] = half_odd_evens[1]
                 odd_evens_dict_rule['half_two_sides_single'] = '单'
                 odd_evens_dict["half_two_sides_double"] = half_odd_evens[3]
@@ -301,32 +296,28 @@ class LanqiuSpider(scrapy.Spider):
             except:
                 # half_odd_even_odd = ""
                 # half_odd_even_even = ""
-                odd_evens_dict["half_two_sides_single"] = None
+                odd_evens_dict["half_two_sides_single"] = ""
                 odd_evens_dict_rule['half_two_sides_single'] = '单'
-                odd_evens_dict["half_two_sides_double"] = None
+                odd_evens_dict["half_two_sides_double"] = ""
                 odd_evens_dict_rule['half_two_sides_double'] = '双'
 
             # 总分:单/双-第一节
             try:
                 one_odd_evens = result['o']["oeq1"]["v"]
-                # one_odd_even_odd,one_odd_even_even = danshaung_fun(inner=one_odd_evens)
                 odd_evens_dict["one_two_sides_single"] = one_odd_evens[1]
                 odd_evens_dict_rule['one_two_sides_single'] = '单'
                 odd_evens_dict["one_two_sides_double"] = one_odd_evens[3]
                 odd_evens_dict_rule['one_two_sides_double'] = '双'
             except:
-                # one_odd_even_odd = ""
-                # one_odd_even_even = ""
-                odd_evens_dict["one_two_sides_single"] = None
+                odd_evens_dict["one_two_sides_single"] = ""
                 odd_evens_dict_rule['one_two_sides_single'] = '单'
-                odd_evens_dict["one_two_sides_double"] = None
+                odd_evens_dict["one_two_sides_double"] = ""
                 odd_evens_dict_rule['one_two_sides_double'] = '双'
 
 
             # 总分:单/双-第二节
             try:
                 two_odd_evens = result['o']["oeq2"]["v"]
-                # two_odd_even_odd,two_odd_even_even = danshaung_fun(inner=two_odd_evens)
                 odd_evens_dict["two_two_sides_single"] = two_odd_evens[1]
                 odd_evens_dict_rule['two_two_sides_single'] = '单'
                 odd_evens_dict["two_two_sides_double"] = two_odd_evens[3]
@@ -334,15 +325,14 @@ class LanqiuSpider(scrapy.Spider):
             except:
                 # two_odd_even_odd = ""
                 # two_odd_even_even = ""
-                odd_evens_dict["two_two_sides_single"] = None
+                odd_evens_dict["two_two_sides_single"] = ""
                 odd_evens_dict_rule['two_two_sides_single'] = '单'
-                odd_evens_dict["two_two_sides_double"] = None
+                odd_evens_dict["two_two_sides_double"] = ""
                 odd_evens_dict_rule['two_two_sides_double'] = '双'
 
             # 总分:单/双-第三节
             try:
                 three_odd_evens = result['o']["oeq3"]["v"]
-                # three_odd_even_odd,three_odd_even_even = danshaung_fun(inner=three_odd_evens)
                 odd_evens_dict["three_two_sides_single"] = three_odd_evens[1]
                 odd_evens_dict_rule['three_two_sides_single'] = '单'
                 odd_evens_dict["three_two_sides_double"] = three_odd_evens[3]
@@ -350,11 +340,9 @@ class LanqiuSpider(scrapy.Spider):
 
 
             except:
-                # three_odd_even_odd = ""
-                # three_odd_even_even = ""
-                odd_evens_dict["three_two_sides_single"] = None
+                odd_evens_dict["three_two_sides_single"] = ""
                 odd_evens_dict_rule['three_two_sides_single'] = '单'
-                odd_evens_dict["three_two_sides_double"] = None
+                odd_evens_dict["three_two_sides_double"] = ""
                 odd_evens_dict_rule['three_two_sides_double'] = '双'
 
 
@@ -362,17 +350,14 @@ class LanqiuSpider(scrapy.Spider):
             # 总分:单/双-第四节
             try:
                 four_odd_evens = result['o']["oeq4"]["v"]
-                # four_odd_even_odd,four_odd_even_even = danshaung_fun(inner=four_odd_evens)
                 odd_evens_dict["four_two_sides_single"] = four_odd_evens[1]
                 odd_evens_dict_rule['four_two_sides_single'] = '单'
                 odd_evens_dict["four_two_sides_double"] = four_odd_evens[3]
                 odd_evens_dict_rule['four_two_sides_double'] = '双'
             except:
-                # four_odd_even_odd = ""
-                # four_odd_even_even = ""
-                odd_evens_dict["four_two_sides_single"] = None
+                odd_evens_dict["four_two_sides_single"] = ""
                 odd_evens_dict_rule['four_two_sides_single'] = '单'
-                odd_evens_dict["four_two_sides_double"] = None
+                odd_evens_dict["four_two_sides_double"] = ""
                 odd_evens_dict_rule['four_two_sides_double'] = '双'
 
 # ----------------------------------------球队得分最后一位数分割线---------------------------------------------------------
@@ -406,10 +391,8 @@ class LanqiuSpider(scrapy.Spider):
                 capots_dict["capot_home"] = capot_home
                 capots_dict["capot_guest"] = capot_guest
             except:
-                # capot_home = ""
-                # capot_guest = ""
-                capots_dict["capot_home"] = None
-                capots_dict["capot_guest"] = None
+                capots_dict["capot_home"] = ""
+                capots_dict["capot_guest"] = ""
 
             # 上半场独赢
             try:
@@ -420,10 +403,8 @@ class LanqiuSpider(scrapy.Spider):
                 capots_dict["half_capot_home"] = half_capot_home
                 capots_dict["half_capot_guest"] = half_capot_guest
             except:
-                # half_capot_home = ""
-                # half_capot_guest = ""
-                capots_dict["half_capot_home"] = None
-                capots_dict["half_capot_guest"] = None
+                capots_dict["half_capot_home"] = ""
+                capots_dict["half_capot_guest"] = ""
 
             # 第一节独赢
             try:
@@ -434,10 +415,8 @@ class LanqiuSpider(scrapy.Spider):
                 capots_dict["one_capot_home"] = one_capot_home
                 capots_dict["one_capot_guest"] = one_capot_guest
             except:
-                # one_capot_home = ""
-                # one_capot_guest = ""
-                capots_dict["one_capot_home"] = None
-                capots_dict["one_capot_guest"] = None
+                capots_dict["one_capot_home"] = ""
+                capots_dict["one_capot_guest"] = ""
 
             # 第二节独赢
             try:
@@ -448,10 +427,8 @@ class LanqiuSpider(scrapy.Spider):
                 capots_dict["two_capot_home"] = two_capot_home
                 capots_dict["two_capot_guest"] = two_capot_guest
             except:
-                # two_capot_home = ""
-                # two_capot_guest = ""
-                capots_dict["two_capot_home"] = None
-                capots_dict["two_capot_guest"] = None
+                capots_dict["two_capot_home"] = ""
+                capots_dict["two_capot_guest"] = ""
 
             # 第三节独赢
             try:
@@ -462,10 +439,8 @@ class LanqiuSpider(scrapy.Spider):
                 capots_dict["three_capot_home"] = three_capot_home
                 capots_dict["three_capot_guest"] = three_capot_guest
             except:
-                # three_capot_home = ""
-                # three_capot_guest = ""
-                capots_dict["three_capot_home"] = None
-                capots_dict["three_capot_guest"] = None
+                capots_dict["three_capot_home"] = ""
+                capots_dict["three_capot_guest"] = ""
 
             # 第四节独赢
             try:
@@ -476,10 +451,8 @@ class LanqiuSpider(scrapy.Spider):
                 capots_dict["four_capot_home"] = four_capot_home
                 capots_dict["four_capot_guest"] = four_capot_guest
             except:
-                # four_capot_home = ""
-                # four_capot_guest = ""
-                capots_dict["four_capot_home"] = None
-                capots_dict["four_capot_guest"] = None
+                capots_dict["four_capot_home"] = ""
+                capots_dict["four_capot_guest"] = ""
 
 # ---------------------------------------------------华丽分割线列表es[1]--------------------------------------------------
             # 球队得分 全场主队 home
@@ -498,14 +471,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["score_home_small"] = score_home_small_rule
                     team_scores_dict["score_home_small"] = score_home_small
                 except:
-                    # score_home_small = ""
-                    # score_home_small_rule = ""
-                    # score_home_big_rule = ""
-                    # score_home_big = ""
-                    team_scores_dict_rule["score_home_big"] = None
-                    team_scores_dict["score_home_big"] = None
-                    team_scores_dict_rule["score_home_small"] = None
-                    team_scores_dict["score_home_small"] = None
+                    team_scores_dict_rule["score_home_big"] = ""
+                    team_scores_dict["score_home_big"] = ""
+                    team_scores_dict_rule["score_home_small"] = ""
+                    team_scores_dict["score_home_small"] = ""
                 # 球队得分 上半场主队 home
                 try:
                     half_score_homes = score_home['o']['ou1st']['v']
@@ -516,14 +485,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["half_score_home_small"] = half_score_home_small_rule
                     team_scores_dict["half_score_home_small"] = half_score_home_small
                 except:
-                    # half_score_home_small = ""
-                    # half_score_home_small_rule = ""
-                    # half_score_home_big = ""
-                    # half_score_home_big_rule = ""
-                    team_scores_dict_rule["half_score_home_big"] = None
-                    team_scores_dict["half_score_home_big"] = None
-                    team_scores_dict_rule["half_score_home_small"] = None
-                    team_scores_dict["half_score_home_small"] = None
+                    team_scores_dict_rule["half_score_home_big"] = ""
+                    team_scores_dict["half_score_home_big"] = ""
+                    team_scores_dict_rule["half_score_home_small"] = ""
+                    team_scores_dict["half_score_home_small"] = ""
 
                 # 球队得分:主队-大 / 小-第一节
                 try:
@@ -534,14 +499,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["one_score_home_small"] = one_score_home_small_rule
                     team_scores_dict["one_score_home_small"] = one_score_home_small
                 except:
-                    # one_score_home_small = ""
-                    # one_score_home_small_rule = ""
-                    # one_score_home_big = ""
-                    # one_score_home_big_rule = ""
-                    team_scores_dict_rule["one_score_home_big"] = None
-                    team_scores_dict["one_score_home_big"] = None
-                    team_scores_dict_rule["one_score_home_small"] = None
-                    team_scores_dict["one_score_home_small"] = None
+                    team_scores_dict_rule["one_score_home_big"] = ""
+                    team_scores_dict["one_score_home_big"] = ""
+                    team_scores_dict_rule["one_score_home_small"] = ""
+                    team_scores_dict["one_score_home_small"] = ""
 
                 # 球队得分:主队-大 / 小-第二节
                 try:
@@ -552,14 +513,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["two_score_home_small"] = two_score_home_small_rule
                     team_scores_dict["two_score_home_small"] = two_score_home_small
                 except:
-                    # two_score_home_small = ""
-                    # two_score_home_small_rule = ""
-                    # two_score_home_big = ""
-                    # two_score_home_big_rule = ""
-                    team_scores_dict_rule["two_score_home_big"] = None
-                    team_scores_dict["two_score_home_big"] = None
-                    team_scores_dict_rule["two_score_home_small"] = None
-                    team_scores_dict["two_score_home_small"] = None
+                    team_scores_dict_rule["two_score_home_big"] = ""
+                    team_scores_dict["two_score_home_big"] = ""
+                    team_scores_dict_rule["two_score_home_small"] = ""
+                    team_scores_dict["two_score_home_small"] = ""
 
                 # 球队得分:主队-大 / 小-第三节
                 try:
@@ -570,14 +527,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["three_score_home_small"] = three_score_home_small_rule
                     team_scores_dict["three_score_home_small"] = three_score_home_small
                 except:
-                    # three_score_home_small = ""
-                    # three_score_home_small_rule = ""
-                    # three_score_home_big = ""
-                    # three_score_home_big_rule = ""
-                    team_scores_dict_rule["three_score_home_big"] = None
-                    team_scores_dict["three_score_home_big"] = None
-                    team_scores_dict_rule["three_score_home_small"] = None
-                    team_scores_dict["three_score_home_small"] = None
+                    team_scores_dict_rule["three_score_home_big"] = ""
+                    team_scores_dict["three_score_home_big"] = ""
+                    team_scores_dict_rule["three_score_home_small"] = ""
+                    team_scores_dict["three_score_home_small"] = ""
 
                 # 球队得分:主队-大 / 小-第四节
                 try:
@@ -588,14 +541,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["four_score_home_small"] = four_score_home_small_rule
                     team_scores_dict["four_score_home_small"] = four_score_home_small
                 except:
-                    # four_score_home_small = ""
-                    # four_score_home_small_rule = ""
-                    # four_score_home_big = ""
-                    # four_score_home_big_rule = ""
-                    team_scores_dict_rule["four_score_home_big"] = None
-                    team_scores_dict["four_score_home_big"] = None
-                    team_scores_dict_rule["four_score_home_small"] = None
-                    team_scores_dict["four_score_home_small"] = None
+                    team_scores_dict_rule["four_score_home_big"] = ""
+                    team_scores_dict["four_score_home_big"] = ""
+                    team_scores_dict_rule["four_score_home_small"] = ""
+                    team_scores_dict["four_score_home_small"] = ""
 
 
 # ---------------------------------------------------华丽分割线列表es[2]--------------------------------------------------
@@ -614,14 +563,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["score_guest_small"] = score_guest_small_rule
                     team_scores_dict["score_guest_small"] = score_guest_small
                 except:
-                    # score_guest_small = ""
-                    # score_guest_small_rule = ""
-                    # score_guest_big = ""
-                    # score_guest_big_rule = ""
-                    team_scores_dict_rule["score_guest_big"] = None
-                    team_scores_dict["score_guest_big"] = None
-                    team_scores_dict_rule["score_guest_small"] = None
-                    team_scores_dict["score_guest_small"] = None
+                    team_scores_dict_rule["score_guest_big"] = ""
+                    team_scores_dict["score_guest_big"] = ""
+                    team_scores_dict_rule["score_guest_small"] = ""
+                    team_scores_dict["score_guest_small"] = ""
 
                 # 球队得分 上半场客队 guest
                 try:
@@ -632,14 +577,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["half_score_guest_small"] = half_score_guest_small_rule
                     team_scores_dict["half_score_guest_small"] = half_score_guest_small
                 except:
-                    # half_score_guest_small = ""
-                    # half_score_guest_small_rule = ""
-                    # half_score_guest_big = ""
-                    # half_score_guest_big_rule = ""
-                    team_scores_dict_rule["half_score_guest_big"] = None
-                    team_scores_dict["half_score_guest_big"] = None
-                    team_scores_dict_rule["half_score_guest_small"] = None
-                    team_scores_dict["half_score_guest_small"] = None
+                    team_scores_dict_rule["half_score_guest_big"] = ""
+                    team_scores_dict["half_score_guest_big"] = ""
+                    team_scores_dict_rule["half_score_guest_small"] = ""
+                    team_scores_dict["half_score_guest_small"] = ""
                 # 球队得分第一节
                 try:
                     one_score_guests = score_guest["o"]['ouq1']['v']
@@ -650,14 +591,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["one_score_guest_small"] = one_score_guest_small_rule
                     team_scores_dict["one_score_guest_small"] = one_score_guest_small
                 except:
-                    # one_score_guest_small = ""
-                    # one_score_guest_small_rule = ""
-                    # one_score_guest_big = ""
-                    # one_score_guest_big_rule = ""
-                    team_scores_dict_rule["one_score_guest_big"] = None
-                    team_scores_dict["one_score_guest_big"] = None
-                    team_scores_dict_rule["one_score_guest_small"] = None
-                    team_scores_dict["one_score_guest_small"] = None
+                    team_scores_dict_rule["one_score_guest_big"] = ""
+                    team_scores_dict["one_score_guest_big"] = ""
+                    team_scores_dict_rule["one_score_guest_small"] = ""
+                    team_scores_dict["one_score_guest_small"] = ""
 
                 # 球队得分第二节
                 try:
@@ -669,10 +606,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["two_score_guest_small"] = two_score_guest_small_rule
                     team_scores_dict["two_score_guest_small"] = two_score_guest_small
                 except:
-                    team_scores_dict_rule["two_score_guest_big"] = None
-                    team_scores_dict["two_score_guest_big"] = None
-                    team_scores_dict_rule["two_score_guest_small"] = None
-                    team_scores_dict["two_score_guest_small"] = None
+                    team_scores_dict_rule["two_score_guest_big"] = ""
+                    team_scores_dict["two_score_guest_big"] = ""
+                    team_scores_dict_rule["two_score_guest_small"] = ""
+                    team_scores_dict["two_score_guest_small"] = ""
                 # 球队得分第三节
                 try:
                     three_score_guests = score_guest["o"]['ouq3']['v']
@@ -683,10 +620,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["three_score_guest_small"] = three_score_guest_small_rule
                     team_scores_dict["three_score_guest_small"] = three_score_guest_small
                 except:
-                    team_scores_dict_rule["three_score_guest_big"] = None
-                    team_scores_dict["three_score_guest_big"] = None
-                    team_scores_dict_rule["three_score_guest_small"] = None
-                    team_scores_dict["three_score_guest_small"] = None
+                    team_scores_dict_rule["three_score_guest_big"] = ""
+                    team_scores_dict["three_score_guest_big"] = ""
+                    team_scores_dict_rule["three_score_guest_small"] = ""
+                    team_scores_dict["three_score_guest_small"] = ""
                 # 球队得分第四节
                 try:
                     four_score_guests = score_guest["o"]['ouq4']['v']
@@ -697,10 +634,10 @@ class LanqiuSpider(scrapy.Spider):
                     team_scores_dict_rule["four_score_guest_small"] = four_score_guest_small_rule
                     team_scores_dict["four_score_guest_small"] = four_score_guest_small
                 except:
-                    team_scores_dict_rule["four_score_guest_big"] = None
-                    team_scores_dict["four_score_guest_big"] = None
-                    team_scores_dict_rule["four_score_guest_small"] = None
-                    team_scores_dict["four_score_guest_small"] = None
+                    team_scores_dict_rule["four_score_guest_big"] = ""
+                    team_scores_dict["four_score_guest_big"] = ""
+                    team_scores_dict_rule["four_score_guest_small"] = ""
+                    team_scores_dict["four_score_guest_small"] = ""
 
             # 联赛id
             item['league_id'] = league_id
@@ -727,7 +664,6 @@ class LanqiuSpider(scrapy.Spider):
             item['score_guest'] = score_guest1
             # 第几节
             item['jijie'] = jijie
-            item['pt'] = pt
             # 球队得分
             item['qiudui'] = qiudui
             item['concede'] = concedes_dict

+ 253 - 232
hg3535/spiders/roll_wangqiu.py

@@ -42,7 +42,7 @@ class WangqiuSpider(scrapy.Spider):
     start_urls = ['https://hg3535z.com/odds2/d/getodds?sid=3&pt=4&ubt=am&pn=0&sb=2&dc=null&pid=0'] # 滚球菜单 网球滚球列url
     custom_settings = {
         "ITEM_PIPELINES": {
-            "hg3535.pipelines.Roll_Wangqiupipeline": 350,
+            "hg3535.pipeline.Roll_Wangqiupipeline": 350,
         },
         # 'LOG_LEVEL': 'DEBUG',
         # 'LOG_FILE': "../hg3535/log/roll_wangqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
@@ -59,7 +59,7 @@ class WangqiuSpider(scrapy.Spider):
         if ids:
             ids = set(ids)
             for i in ids:
-                urls = 'https://hg3535z.com/odds2/d/getamodds?eid={}&iip=true&ubt=am&isp=false'.format(i)
+                urls = 'https://www.hg3535z.com/odds2/d/getamodds?eid={}&iip=true&ubt=am&isp=false'.format(i)
                 print(urls)
                 yield Request(url=urls, callback=self.parse_other)
 
@@ -76,246 +76,267 @@ class WangqiuSpider(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]
-            try:
-                time_game = result['sb']['ct']
-            except:
-                time_game = '01:00'
-            # time_game = '00:00:00'
-            # time_game = result.get('sb',"").get('ct',"")
-            # 队1分数
-            score_home1 = result['i'][10]
-            # 队2分数
-            score_guest1 = result['i'][11]
-            # 第几节
-            jijie = result['i'][12]
-            # 球队得分
-            qiudui = result['pci'].get('ctn', "")
+            for result in new_data:
+                # 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]
+                try:
+                    time_game = result['sb']['ct']
+                except:
+                    time_game = '01:00'
+                # time_game = '00:00:00'
+                # time_game = result.get('sb',"").get('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"]
-                concedes_dict_rule['dishes_home'] = concedes[1]
-                concedes_dict['dishes_home'] = concedes[5]
-                concedes_dict_rule['dishes_guest'] = concedes[3]
-                concedes_dict['dishes_guest'] = concedes[7]
-            except:
-                concedes_dict_rule['dishes_home'] = ""
-                concedes_dict['dishes_home'] = ""
-                concedes_dict_rule['dishes_guest'] = ""
-                concedes_dict['dishes_guest'] = ""
-            # print(concedes_dict)
-
-# ----------------------------------------第一节让球分割线---------------------------------------------------------------------------
-
-            #第一节让盘
-            try:
-                # 第一节让球
-                one_concedes = result['o']["ahs1"]["v"]
-                concedes_dict_rule['one_dishes_home'] = one_concedes[1]
-                concedes_dict['one_dishes_home'] = one_concedes[5]
-                concedes_dict_rule['one_dishes_guest'] = one_concedes[3]
-                concedes_dict['one_dishes_guest'] = one_concedes[7]
-            except:
-                concedes_dict_rule['one_dishes_home'] = ""
-                concedes_dict['one_dishes_home'] = ""
-                concedes_dict_rule['one_dishes_guest'] = ""
-                concedes_dict['one_dishes_guest'] = ""
-
-# ----------------------------------------第二节让球分割线-----------------------------------------------------------------
-
-            # 第二节让盘
-            try:
-                two_concedes = result['o']["ahs2"]["v"]
-                concedes_dict_rule['two_dishes_home'] = two_concedes[1]
-                concedes_dict['two_dishes_home'] = two_concedes[5]
-                concedes_dict_rule['two_dishes_guest'] = two_concedes[3]
-                concedes_dict['two_dishes_guest'] = two_concedes[7]
-            except:
-                concedes_dict_rule['two_dishes_home'] = ""
-                concedes_dict['two_dishes_home'] = ""
-                concedes_dict_rule['two_dishes_guest'] = ""
-                concedes_dict['two_dishes_guest'] = ""
-
+                concedes_dict = {}
+                concedes_dict_rule = {}
+                try:
+                    # 滚球让盘
+                    concedes = result['o']["ah"]["v"]
+                    concedes_dict_rule['dishes_home'] = concedes[1]
+                    concedes_dict['dishes_home'] = concedes[5]
+                    concedes_dict_rule['dishes_guest'] = concedes[3]
+                    concedes_dict['dishes_guest'] = concedes[7]
+                except:
+                    concedes_dict_rule['dishes_home'] = ""
+                    concedes_dict['dishes_home'] = ""
+                    concedes_dict_rule['dishes_guest'] = ""
+                    concedes_dict['dishes_guest'] = ""
+                # print(concedes_dict)
+
+# ----------------------------------------第一节让球分割线----------------------------------------------------------------
+                #第一节让盘
+                try:
+                    # 第一节让球
+                    one_concedes = result['o']["ahs1"]["v"]
+                    concedes_dict_rule['one_dishes_home'] = one_concedes[1]
+                    concedes_dict['one_dishes_home'] = one_concedes[5]
+                    concedes_dict_rule['one_dishes_guest'] = one_concedes[3]
+                    concedes_dict['one_dishes_guest'] = one_concedes[7]
+                except:
+                    concedes_dict_rule['one_dishes_home'] = ""
+                    concedes_dict['one_dishes_home'] = ""
+                    concedes_dict_rule['one_dishes_guest'] = ""
+                    concedes_dict['one_dishes_guest'] = ""
+
+# ----------------------------------------第二节让球分割线----------------------------------------------------------------
+
+                # 第二节让盘
+                try:
+                    two_concedes = result['o']["ahs2"]["v"]
+                    concedes_dict_rule['two_dishes_home'] = two_concedes[1]
+                    concedes_dict['two_dishes_home'] = two_concedes[5]
+                    concedes_dict_rule['two_dishes_guest'] = two_concedes[3]
+                    concedes_dict['two_dishes_guest'] = two_concedes[7]
+                except:
+                    concedes_dict_rule['two_dishes_home'] = ""
+                    concedes_dict['two_dishes_home'] = ""
+                    concedes_dict_rule['two_dishes_guest'] = ""
+                    concedes_dict['two_dishes_guest'] = ""
 
 # ---------------------------------------------------冠军  滚球是独赢-----------------------------------------------------
-            kemps_dict = {}
-            try:
-                kemps = result['o']["ml"]["v"]
-                kemps_dict['kemp_home'] = kemps[1]
-                kemps_dict['kemp_guest'] = kemps[3]
-
-            except:
-                kemps_dict['kemp_home'] = ""
-                kemps_dict['kemp_guest'] = ""
-            # 第一盘 冠军  第一盘独赢 滚球是独赢
-            try:
-                kemps = result['o']["mls1"]["v"]
-                kemps_dict['one_kemp_home'] = kemps[1]
-                kemps_dict['one_kemp_guest'] = kemps[3]
-
-            except:
-                kemps_dict['one_kemp_home'] = ""
-                kemps_dict['one_kemp_guest'] = ""
-
-            try: # 第二盘 独赢
-                kemps = result['o']["mls2"]["v"]
-                kemps_dict['two_kemp_home'] = kemps[1]
-                kemps_dict['two_kemp_guest'] = kemps[3]
-            except:
-                kemps_dict['two_kemp_home'] = ""
-                kemps_dict["two_kemp_guest"] = ""
-
+                kemps_dict = {}
+                try:
+                    kemps = result['o']["ml"]["v"]
+                    kemps_dict['kemp_home'] = kemps[1]
+                    kemps_dict['kemp_guest'] = kemps[3]
+
+                except:
+                    kemps_dict['kemp_home'] = ""
+                    kemps_dict['kemp_guest'] = ""
+                # 第一盘 冠军  第一盘独赢 滚球是独赢
+                try:
+                    kemps = result['o']["mls1"]["v"]
+                    kemps_dict['one_kemp_home'] = kemps[1]
+                    kemps_dict['one_kemp_guest'] = kemps[3]
+
+                except:
+                    kemps_dict['one_kemp_home'] = ""
+                    kemps_dict['one_kemp_guest'] = ""
+
+                try: # 第二盘 独赢
+                    kemps = result['o']["mls2"]["v"]
+                    kemps_dict['two_kemp_home'] = kemps[1]
+                    kemps_dict['two_kemp_guest'] = kemps[3]
+                except:
+                    kemps_dict['two_kemp_home'] = ""
+                    kemps_dict["two_kemp_guest"] = ""
 
 # ---------------------------------------------------让局---------------------------------------------------------------
 
-            bureaus_dict = {}
-            bureaus_dict_rule = {}
-            try:
-                bureaus = result['o']["ahfts"]["v"]
-                if bureaus:
-                    a = bureaus
-                bureaus_dict_rule['concede_home'] = bureaus[1]
-                bureaus_dict['concede_home'] = bureaus[5]
-                bureaus_dict_rule['concede_guest'] = bureaus[3]
-                bureaus_dict['concede_guest'] = bureaus[7]
-            except:
-                bureaus_dict_rule['concede_home'] = ""
-                bureaus_dict['concede_home'] = ""
-                bureaus_dict_rule['concede_guest'] = ""
-                bureaus_dict['concede_guest'] = ""
+                bureaus_dict = {}
+                bureaus_dict_rule = {}
+                try:
+                    bureaus = result['o']["ahfts"]["v"]
+                    bureaus_dict_rule['concede_home'] = bureaus[1]
+                    bureaus_dict['concede_home'] = bureaus[5]
+                    bureaus_dict_rule['concede_guest'] = bureaus[3]
+                    bureaus_dict['concede_guest'] = bureaus[7]
+                except:
+                    bureaus_dict_rule['concede_home'] = ""
+                    bureaus_dict['concede_home'] = ""
+                    bureaus_dict_rule['concede_guest'] = ""
+                    bureaus_dict['concede_guest'] = ""
 
 # -----------------------------------------------------总局数 第一盘:大/小------------------------------------------------
-            total_number_dict = {}
-            total_number_dict_rule = {}
-            try:  #总局数 滚球大小
-                total_numbers = result['o']["oufts"]["v"]
-                total_number_dict_rule['total_number_big'] = total_numbers[1]
-                total_number_dict['total_number_big'] = total_numbers[5]
-                total_number_dict_rule['total_number_small'] = total_numbers[3]
-                total_number_dict['total_number_small'] = total_numbers[7]
-            except:
-                total_number_dict_rule['total_number_big'] = ""
-                total_number_dict['total_number_big'] = ""
-                total_number_dict_rule['total_number_small'] = ""
-                total_number_dict['total_number_small'] = ""
-
-            # 第一节盘
-            try:
-                one_total_sizes = result['o']["ous1"]["v"]
-                total_number_dict_rule["one_total_sizes_big"] = one_total_sizes[1]
-                total_number_dict["one_total_sizes_big"] = one_total_sizes[5]
-                total_number_dict_rule["one_total_sizes_small"] = one_total_sizes[3]
-                total_number_dict["one_total_sizes_small"] = one_total_sizes[7]
-            except:
-                total_number_dict_rule["one_total_sizes_big"] = ""
-                total_number_dict["one_total_sizes_big"] = ""
-                total_number_dict_rule["one_total_sizes_small"] = ""
-                total_number_dict["one_total_sizes_small"] = ""
-
-            # 第二节盘
-            try:
-                two_total_sizes = result['o']["ous2"]["v"]
-                total_number_dict_rule["two_total_sizes_big"] = two_total_sizes[1]
-                total_number_dict["two_total_sizes_big"] = two_total_sizes[5]
-                total_number_dict_rule["two_total_sizes_small"] = two_total_sizes[3]
-                total_number_dict["two_total_sizes_small"] = two_total_sizes[7]
-            except:
-                total_number_dict_rule["two_total_sizes_big"] = ""
-                total_number_dict["two_total_sizes_big"] = ""
-                total_number_dict_rule["two_total_sizes_small"] = ""
-                total_number_dict["two_total_sizes_small"] = ""
-
-
-            # 第三节盘
-            try:
-                three_total_sizes = result['o']["ous3"]["v"]
-                total_number_dict_rule["three_total_sizes_big"] = three_total_sizes[1]
-                total_number_dict["three_total_sizes_big"] = three_total_sizes[5]
-                total_number_dict_rule["three_total_sizes_small"] = three_total_sizes[3]
-                total_number_dict["three_total_sizes_small"] = three_total_sizes[7]
-            except:
-                total_number_dict_rule["three_total_sizes_big"] = ""
-                total_number_dict["three_total_sizes_big"] = ""
-                total_number_dict_rule["three_total_sizes_small"] = ""
-                total_number_dict["three_total_sizes_small"] = ""
-
+                total_number_dict = {}
+                total_number_dict_rule = {}
+                try:  #总局数 滚球大小
+                    total_numbers = result['o']["oufts"]["v"]
+                    total_number_dict_rule['total_number_big'] = total_numbers[1]
+                    total_number_dict['total_number_big'] = total_numbers[5]
+                    total_number_dict_rule['total_number_small'] = total_numbers[3]
+                    total_number_dict['total_number_small'] = total_numbers[7]
+                except:
+                    total_number_dict_rule['total_number_big'] = ""
+                    total_number_dict['total_number_big'] = ""
+                    total_number_dict_rule['total_number_small'] = ""
+                    total_number_dict['total_number_small'] = ""
+
+                # 第一节盘
+                try:
+                    one_total_sizes = result['o']["ous1"]["v"]
+                    total_number_dict_rule["one_total_number_big"] = one_total_sizes[1]
+                    total_number_dict["one_total_number_big"] = one_total_sizes[5]
+                    total_number_dict_rule["one_total_number_small"] = one_total_sizes[3]
+                    total_number_dict["one_total_number_small"] = one_total_sizes[7]
+                except:
+                    total_number_dict_rule["one_total_number_big"] = ""
+                    total_number_dict["one_total_number_big"] = ""
+                    total_number_dict_rule["one_total_number_small"] = ""
+                    total_number_dict["one_total_number_small"] = ""
+
+                # 第二节盘
+                try:
+                    two_total_sizes = result['o']["ous2"]["v"]
+                    total_number_dict_rule["two_total_number_big"] = two_total_sizes[1]
+                    total_number_dict["two_total_number_big"] = two_total_sizes[5]
+                    total_number_dict_rule["two_total_number_small"] = two_total_sizes[3]
+                    total_number_dict["two_total_number_small"] = two_total_sizes[7]
+                except:
+                    total_number_dict_rule["two_total_number_big"] = ""
+                    total_number_dict["two_total_number_big"] = ""
+                    total_number_dict_rule["two_total_number_small"] = ""
+                    total_number_dict["two_total_number_small"] = ""
+
+
+                # 第三节盘
+                try:
+                    three_total_sizes = result['o']["ous3"]["v"]
+                    total_number_dict_rule["three_total_number_big"] = three_total_sizes[1]
+                    total_number_dict["three_total_number_big"] = three_total_sizes[5]
+                    total_number_dict_rule["three_total_number_small"] = three_total_sizes[3]
+                    total_number_dict["three_total_number_small"] = three_total_sizes[7]
+                except:
+                    total_number_dict_rule["three_total_number_big"] = ""
+                    total_number_dict["three_total_number_big"] = ""
+                    total_number_dict_rule["three_total_number_small"] = ""
+                    total_number_dict["three_total_number_small"] = ""
 
 # ------------------------------------------------------总局数:单/双-----------------------------------------------------
-            odd_evens_dict = {}
-            odd_evens_dict_rule = {}
-            try:
-                odd_evens = result['o']["oefts"]["v"]
-                # 上半场 主队让球条件
-                odd_evens_dict['two_sides_single'] = odd_evens[1] # 之前是odd_even_odd
-                odd_evens_dict_rule['two_sides_single'] = "单"
-                odd_evens_dict['two_sides_double'] = odd_evens[3]
-                odd_evens_dict_rule['two_sides_double'] = "双"
-
-            except:
-                odd_evens_dict['two_sides_single'] = ""
-                odd_evens_dict['two_sides_double'] = ""
-                odd_evens_dict_rule['two_sides_double'] = ""
-                odd_evens_dict_rule['two_sides_single'] = ""
-
-            # 联赛id
-            item['league_id'] = league_id
-            # 联赛名
-            item['league_name'] = league_name
-            # 比赛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['pt'] = pt
-            # 球队得分
-            item['qiudui'] = qiudui
-            # 让盘
-            item['concedes_dict'] = concedes_dict
-            item['concedes_dict_rule'] = concedes_dict_rule
-            # 冠军
-            item['kemps_dict'] = kemps_dict
-            # 让局
-            item['bureaus_dict'] = bureaus_dict
-            item['bureaus_dict_rule'] = bureaus_dict_rule
-            # 总局数大小
-            item['total_number_dict'] = total_number_dict
-            item['total_number_dict_rule'] = total_number_dict_rule
-            # 总局数单双
-            item['odd_evens_dict'] = odd_evens_dict
-            item['odd_evens_dict_rule'] = odd_evens_dict_rule
-            yield item
+                odd_evens_dict = {}
+                odd_evens_dict_rule = {}
+                try:
+                    odd_evens = result['o']["oefts"]["v"]
+                    # 上半场 主队让球条件
+                    odd_evens_dict['two_sides_single'] = odd_evens[1] # 之前是odd_even_odd
+                    odd_evens_dict_rule['two_sides_single'] = "单"
+                    odd_evens_dict['two_sides_double'] = odd_evens[3]
+                    odd_evens_dict_rule['two_sides_double'] = "双"
+
+                except:
+                    odd_evens_dict['two_sides_single'] = ""
+                    odd_evens_dict['two_sides_double'] = ""
+                    odd_evens_dict_rule['two_sides_double'] = ""
+                    odd_evens_dict_rule['two_sides_single'] = ""
+
+                # 盘,局,点
+                sq_dict = {}
+                try:
+                    saiqing = []
+                    # h为第一个队伍,a为第二个队伍
+                    s = result['sb']['cp']
+                    cps = result['sb']['ps']
+                    # 队伍1
+                    h = result['sb']['h']
+                    # 队伍2
+                    a = result['sb']['a']
+                    for cp in cps:
+                        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
+                # 联赛id
+                item['league_id'] = league_id
+                # 联赛名
+                item['league_name'] = league_name
+                # 比赛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'] = h
+                # 队2分数
+                item['score_guest'] = a
+                # 第几节
+                item['jijie'] = s
+                item['pt'] = pt
+                # 球队得分
+                item['qiudui'] = qiudui
+                # 让盘
+                item['concedes_dict'] = concedes_dict
+                item['concedes_dict_rule'] = concedes_dict_rule
+                # 冠军
+                item['kemps_dict'] = kemps_dict
+                # 让局
+                item['bureaus_dict'] = bureaus_dict
+                item['bureaus_dict_rule'] = bureaus_dict_rule
+                # 总局数大小
+                item['total_number_dict'] = total_number_dict
+                item['total_number_dict_rule'] = total_number_dict_rule
+                # 总局数单双
+                item['odd_evens_dict'] = odd_evens_dict
+                item['odd_evens_dict_rule'] = odd_evens_dict_rule
+                item['sq_dict'] = sq_dict
+                yield item
 
 
 

+ 46 - 60
hg3535/spiders/roll_zuqiu.py

@@ -16,25 +16,44 @@ class ZuqiuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES":{
-            'hg3535.pipelines.Roll_Zuqiupipeline': 100,
+            'hg3535.pipeline.roll_zuqiu.Roll_Zuqiupipeline': 200,
         },
         # 'LOG_LEVEL': 'DEBUG',
         # 'LOG_FILE': "../hg3535/log/roll_zuqiu_{}_{}_{}.log".format(to_day.year, to_day.month,to_day.day)
     }
-    start_urls = ['https://hg3535z.com/odds2/d/getodds?sid=1&pt=4&ubt=am&pn=0&sb=2&dc=null&pid=0'] # 滚球菜单 足球滚球列url
-
+    start_urls = ['https://odata.jiushan6688.com/odds6i/d/getodds/zh-cn/sid/1/pt/4/ubt/am/pn/0/sb/2/dc/null/pid/0']
 
     def parse(self, response):
-        datas = json.loads(response.text)
-        # item = Today_all()
-        ids = jsonpath.jsonpath(datas, '$..i-ot[0]..egs..es..i[16]') # ids新列表
-        print(ids)
-        if ids:
-            ids = set(ids)
-            for i in ids:
-                urls = 'https://hg3535z.com/odds2/d/getamodds?eid={}&iip=true&ubt=am&isp=false'.format(i)
-                print(urls)
-                yield Request(url=urls, callback=self.parse_each,dont_filter=True)
+        responses = json.loads(response.text)
+        # try:
+        #     datas = responses.get("i-ot", "")["egs"]
+        # except:
+        #     print("暂无滚球足球数据")
+        #     return
+        # if datas:
+        #     for data in datas:
+        #         match_ids = data['es']
+        #         for match_id in match_ids:
+        #             match_id = str(match_id['i'][16])
+        #             url = 'https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/true/ubt/am/isp/false'.format(match_id)
+        #             yield Request(url=url, callback=self.parse_each, dont_filter=True)
+        try:
+            datas = responses["i-ot"]
+        except:
+            print("暂无滚球篮球数据")
+            return
+        if datas:
+            for data in datas:
+                egs = data['egs']
+                for es in egs:
+                    es = es['es']
+                    for e in es:
+                        match_id = str(e['i'][16])
+                        url = 'https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/true/ubt/am/isp/false'.format(match_id)
+                        yield Request(url=url, callback=self.parse_each, dont_filter=True)
+        else:
+            print("暂无滚球足球数据")
+            return
 
     def parse_each(self, response):
         # 球队进球数 大小
@@ -48,10 +67,7 @@ class ZuqiuSpider(scrapy.Spider):
             league_id = ""
             # 联赛名
             league_name = ""
-        try:
-            pt = response.meta['pt']
-        except:
-            pt = 0
+
         if datas:
             item = Roll_Zuqiu()
             full_dict = {}
@@ -85,26 +101,19 @@ class ZuqiuSpider(scrapy.Spider):
                     score_guest = data['i'][11] # 队二分数
                     # half_way = new_result['i'][12] #下半场
 
-
 # 让球------------------------------------------------------------------------------------------------------------------
                     try:
                         concedes = data['o']['ah']['v']
                         new_concedes = [concedes[i] for i in range(len(concedes)) if i % 2 == 1]
                         concede_homes = [new_concedes[i] for i in range(len(new_concedes)) if i % 2 == 0]
                         concede_home_rule = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 == 0]
-                        if pt is 3:
-                            concede_home = [round(float(concede_homes[i]) - 1, 2) for i in range(len(concede_homes)) if i % 2 is 1]
-                        else:
-                            concede_home = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 is 1]
+                        concede_home = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 is 1]
 
                         concede_guests = [new_concedes[i] for i in range(len(new_concedes)) if i % 2 is 1]
                         # concede_guest_rule
                         # concede_guest
                         concede_guest_rule = [concede_guests[i] for i in range(len(concede_guests)) if i % 2 == 0]
-                        if pt is 3:
-                            concede_guest = [round(float(concede_guests[i]) - 1, 2) for i in range(len(concede_guests)) if i % 2 is 1]
-                        else:
-                            concede_guest = [concede_guests[i] for i in range(len(concede_guests)) if i % 2 is 1]
+                        concede_guest = [concede_guests[i] for i in range(len(concede_guests)) if i % 2 is 1]
                     except:
                         concede_guest = ""
                         concede_guest_rule = ""
@@ -119,19 +128,12 @@ class ZuqiuSpider(scrapy.Spider):
                                                   i % 2 is 0]
                         half_concede_guest_rule = [new_half_concede_homes[i] for i in range(len(new_half_concede_homes)) if i % 2 == 0]
                         # concede_home
-                        if pt is 3:
-                            half_concede_home = [round(float(new_half_concede_homes[i]) - 1, 2) for i in range(len(new_half_concede_homes)) if i % 2 is 1]
-                        else:
-                            half_concede_home = [new_half_concede_homes[i] for i in range(len(new_half_concede_homes)) if i % 2 is 1]
+                        half_concede_home = [new_half_concede_homes[i] for i in range(len(new_half_concede_homes)) if i % 2 is 1]
                         half_concede_guests = [new_half_concedes[i] for i in range(len(new_half_concedes)) if i % 2 is 1]
                         half_concede_home_rule = [half_concede_guests[i] for i in range(len(half_concede_guests)) if i % 2 == 0]
                         # concede_guest
-                        if pt is 3:
-                            half_concede_guest = [round(float(half_concede_guests[i]) -1, 2)  for i in range(len(half_concede_guests)) if
-                                                  i % 2 is 1]
-                        else:
-                            half_concede_guest = [half_concede_guests[i] for i in range(len(half_concede_guests)) if
-                                                  i % 2 is 1]
+                        half_concede_guest = [half_concede_guests[i] for i in range(len(half_concede_guests)) if
+                                              i % 2 is 1]
                     except:
                         half_concede_home_rule = ""
                         half_concede_home = ""
@@ -146,19 +148,13 @@ class ZuqiuSpider(scrapy.Spider):
                         # size_home_rule
                         size_home_rule = [size_homes[i] for i in range(len(size_homes)) if i % 2 is 0]
                         # size_home
-                        if pt is 3:
-                            size_home = [round(float(size_homes[i]) - 1, 2) for i in range(len(size_homes)) if i % 2 is 1]
-                        else:
-                            size_home = [size_homes[i] for i in range(len(size_homes)) if i % 2 is 1]
+                        size_home = [size_homes[i] for i in range(len(size_homes)) if i % 2 is 1]
 
                         size_guests = [new_sizes[i] for i in range(len(new_sizes)) if i % 2 is 1]
                         # size_guest_rule
                         size_guest_rule = [size_guests[i] for i in range(len(size_guests)) if i % 2 is 0]
                         # csize_guest
-                        if pt is 3:
-                            size_guest = [round(float(size_guests[i]) - 1, 2) for i in range(len(size_guests)) if i % 2 is 1]
-                        else:
-                            size_guest = [size_guests[i] for i in range(len(size_guests)) if i % 2 is 1]
+                        size_guest = [size_guests[i] for i in range(len(size_guests)) if i % 2 is 1]
                     except:
                         size_guest = ""
                         size_guest_rule = ""
@@ -171,24 +167,16 @@ class ZuqiuSpider(scrapy.Spider):
                         new_half_sizes = [half_sizes[i] for i in range(len(half_sizes)) if i % 2 is 1]
                         half_size_homes = [new_half_sizes[i] for i in range(len(new_half_sizes)) if i % 2 is 0]
                         # size_home_rule
-                        half_size_home_rule = [half_size_homes[i] for i in range(len(half_size_homes)) if
-                                               i % 2 is 0]
+                        half_size_home_rule = [half_size_homes[i] for i in range(len(half_size_homes)) if i % 2 is 0]
                         # half_size_home 主队
-                        if pt is 3:
-                            half_size_home = [round(float(half_size_homes[i]) - 1, 2) for i in range(len(half_size_homes)) if i % 2 is 1]
-                        else:
-                            half_size_home = [half_size_homes[i] for i in range(len(half_size_homes)) if i % 2 is 1]
+
+                        half_size_home = [half_size_homes[i] for i in range(len(half_size_homes)) if i % 2 is 1]
                         half_size_guests = [new_half_sizes[i] for i in range(len(new_half_sizes)) if i % 2 is 1]
                         # half_size_guest_rule 客队
-                        half_size_guest_rule = [half_size_guests[i] for i in range(len(half_size_guests)) if
-                                                i % 2 is 0]
+                        half_size_guest_rule = [half_size_guests[i] for i in range(len(half_size_guests)) if i % 2 is 0]
                         # half_size_guest
-                        if pt is 3:
-                            half_size_guest = [round(float(half_size_guests[i]) - 1, 2) for i in range(len(half_size_guests)) if
-                                               i % 2 is 1]
-                        else:
-                            half_size_guest = [half_size_guests[i] for i in range(len(half_size_guests)) if
-                                               i % 2 is 1]
+                        half_size_guest = [half_size_guests[i] for i in range(len(half_size_guests)) if
+                                           i % 2 is 1]
                     except:
                         half_size_guest = ""
                         half_size_guest_rule = ""
@@ -451,10 +439,8 @@ class ZuqiuSpider(scrapy.Spider):
 
                         half_dict_rule['half_guest_tema_ball_small'] = ""
                         half_dict['half_guest_tema_ball_small'] = ""
-
             item['league_id'] = league_id
             item['league_name'] = league_name
-            item['pt'] = pt
             item['game_id'] = game_id
             item['team_home'] = team_home
             item['team_guest'] = team_guest

+ 21 - 3
hg3535/spiders/wangqiu.py

@@ -17,7 +17,7 @@ class LanqiuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES": {
-            "hg3535.pipelines.Wangqiupipeline": 300,
+            "hg3535.pipeline.Wangqiupipeline": 300,
         },
         'LOG_LEVEL': 'DEBUG',
         'LOG_FILE': "../hg3535/log/wangqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
@@ -168,6 +168,24 @@ class LanqiuSpider(scrapy.Spider):
                     total_number_dict['total_number_big'] = ""
                     total_number_dict_rule['total_number_small'] = ""
                     total_number_dict['total_number_small'] = ""
+                # 第一节盘
+                try:
+                    one_total_sizes = result['o']["ous1"]["v"]
+                    total_number_dict_rule["one_total_number_big"] = one_total_sizes[1]
+                    total_number_dict["one_total_number_big"] = one_total_sizes[5]
+                    total_number_dict_rule["one_total_number_small"] = one_total_sizes[3]
+                    total_number_dict["one_total_number_small"] = one_total_sizes[7]
+                    if pt is 3:
+                        total_number_dict['total_number_big'] = float(one_total_sizes[5]) - 1
+                        total_number_dict['total_number_small'] = float(one_total_sizes[7]) - 1
+                    else:
+                        total_number_dict['total_number_big'] = one_total_sizes[5]
+                        total_number_dict['total_number_small'] = one_total_sizes[7]
+                except:
+                    total_number_dict_rule["one_total_number_big"] = ""
+                    total_number_dict["one_total_number_big"] = ""
+                    total_number_dict_rule["one_total_number_small"] = ""
+                    total_number_dict["one_total_number_small"] = ""
 
 # ------------------------------------------------------总局数:单/双-----------------------------------------------------
                 odd_evens_dict = {}
@@ -182,8 +200,8 @@ class LanqiuSpider(scrapy.Spider):
 
                 except:
                     odd_evens_dict['two_sides_single'] = ""
-                    odd_evens_dict['two_sides_single'] = ""
-                    odd_evens_dict_rule['two_sides_double'] = ""
+                    odd_evens_dict['two_sides_double'] = ""
+                    odd_evens_dict_rule['two_sides_single'] = ""
                     odd_evens_dict_rule['two_sides_double'] = ""
 
                 # 联赛id

+ 7 - 11
hg3535/spiders/wq_jieshu.py

@@ -13,12 +13,12 @@ class HgjieshuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES":{
-            'hg3535.pipelines.Wangjieshuqiupipeline': 300,
+            'hg3535.pipeline.Wangjieshuqiupipeline': 300,
         },
         'LOG_LEVEL': 'DEBUG',
         'LOG_FILE': "../hg3535/log/wq_jieshu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
     }
-    start_urls = ['https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/3/normal/1']
+    start_urls = ['https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/3/normal/1', 'https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/3/normal/1']
 
     def parse(self, response):
         if response.status == 200:
@@ -47,16 +47,12 @@ class HgjieshuSpider(scrapy.Spider):
                 except:
                     c = ""
                     temascore_list.append(c)
-            # print(temaid_list)
-            # print(temascore_list)
-            # print(len(temaid_list))
-            # print(len(temascore_list))
             # 赛事id,赛事比元组列表
             tema_tupe = {(temaid_list[i], temascore_list[i]) for i in range(len(temaid_list))}
-            # print(tema_tupe)
-            # print(len(tema_tupe))
+            id_list = []
+            item = Wangjieguo()
             for y in tema_tupe:
                 if y[1]:
-                    item = Wangjieguo()
-                    item['id_score'] = y
-                    yield item
+                    id_list.append(y[0])
+            item['id_score'] = id_list
+            yield item

+ 1 - 1
hg3535/spiders/wqbodan.py

@@ -16,7 +16,7 @@ class WgbodanSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES": {
-            'hg3535.pipelines.Wqbodanpipeline': 300,
+            'hg3535.pipeline.Wqbodanpipeline': 300,
         },
         'LOG_LEVEL': 'DEBUG',
         'LOG_FILE': "../hg3535/log/wqbodan_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)

+ 9 - 19
hg3535/spiders/zq_jieshu.py

@@ -14,17 +14,12 @@ class HgjieshuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES":{
-            'hg3535.pipelines.Zujieshuqiupipeline': 300,
+            'hg3535.pipeline.Zujieshuqiupipeline': 300,
         },
-        'LOG_LEVEL': 'DEBUG',
-        'LOG_FILE': "../hg3535/log/zq_jieshu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
+        # 'LOG_LEVEL': 'DEBUG',
+        # 'LOG_FILE': "../hg3535/log/zq_jieshu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
     }
-    # start_urls = ['https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/1/normal/1', 'https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/1/normal/2']
-
-    def start_requests(self):
-        urls = ['https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/1/normal/1','https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/1/normal/2']
-        for url in urls:
-            yield scrapy.Request(url, callback=self.parse, dont_filter=True)
+    start_urls = ['https://hg3535z.com/zh-cn/info-centre/sportsbook-info/results/1/normal/1']
 
     def parse(self, response):
         if response.status == 200:
@@ -54,18 +49,13 @@ class HgjieshuSpider(scrapy.Spider):
                 except:
                     c = ""
                     temascore_list.append(c)
-            # print(temaid_list)
-            # print(temascore_list)
-            # print(len(temaid_list))
-            # print(len(temascore_list))
             # 赛事id,赛事比元组列表
             tema_tupe = {(temaid_list[i], temascore_list[i]) for i in range(len(temaid_list))}
             print(tema_tupe)
-            # print(tema_tupe)
-            # print(len(tema_tupe))
-
+            id_list = []
+            item = Zujieguo()
             for y in tema_tupe:
                 if y[1]:
-                    item = Zujieguo()
-                    item['id_score'] = y
-                    yield item
+                    id_list.append(y[0])
+            item['id_score'] = id_list
+            yield item

+ 26 - 28
hg3535/spiders/zuqiu.py

@@ -5,11 +5,9 @@ import json
 import scrapy
 from scrapy.http import Request
 from .. items import Zuqiu
-# from scrapy.spidermiddlewares.httperror import HttpError
-# from twisted.internet.error import DNSLookupError
-# from twisted.internet.error import TimeoutError
-
 import datetime
+
+
 class ZuqiuSpider(scrapy.Spider):
     name = 'zuqiu'
     to_day = datetime.datetime.now()
@@ -17,7 +15,7 @@ class ZuqiuSpider(scrapy.Spider):
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES":{
-            'hg3535.pipelines.Zuqiupipeline': 300,
+            'hg3535.pipeline.zuqiu.Zuqiupipeline': 300,
         },
         # 'LOG_LEVEL': 'DEBUG',
         # 'LOG_FILE': "../hg3535/log/zuqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day),
@@ -29,13 +27,13 @@ class ZuqiuSpider(scrapy.Spider):
     }
 
     def start_requests(self):
-
         for y in range(1, 4):
             for i in range(10):
-                url = 'https://hg3535z.com/odds2/d/getodds?sid=1&pt=' + str(y) + '&ubt=' + 'am' + '&pn=' + str(
-                    i) + '&sb=2&dc=null&pid=0'
-                yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y}, dont_filter=True)
-                # yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y})
+                y = str(y)
+                i = str(i)
+                # yield y
+                url = "https://odata.jiushan6688.com/odds6i/d/getodds/zh-cn/sid/1/pt/"+y+"/ubt/am/pn/"+i+"/sb/2/dc/null/pid/0"
+                yield scrapy.Request(url=url, callback=self.parse, dont_filter=True, meta={'pt': y})
 
     def parse(self, response):
         if response.status == 200:
@@ -43,26 +41,26 @@ class ZuqiuSpider(scrapy.Spider):
                 try:
                     datas = json.loads(response.text).get('n-ot', "").get('egs', "")
                 except:
-                    datas = ""
+                    # datas = ''
+                    print("为获取到数据")
+                    return
                 pt = copy.copy(response.meta['pt'])
-                if datas:
-                    for result in datas:
-                        new_results = result['es']
-                        for new_result in new_results:
-                            game_id = str(new_result['i'][16])
-                            if pt is 3:
-                                url = "https://hg3535z.com/odds2/d/getamodds?eid="+game_id+"&iip=false&ubt=am&isp=true"
-                                yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
-                                # yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
-                            if pt is 2:
-                                url = "https://hg3535z.com/odds2/d/getamodds?eid="+game_id+"&iip=false&ubt=am&isp=false"
-                                yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
-                                # yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
-                            if pt is 1:
-                                url = "https://hg3535z.com/odds2/d/getamodds?eid="+game_id+"&iip=false&ubt=am&isp=false"
-                                yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
-                                # yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
 
+                for result in datas:
+                    new_results = result['es']
+                    for new_result in new_results:
+                        game_id = str(new_result['i'][16])
+                        pass
+                        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})
+                        if pt == "2":
+                            url = "https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/"+str(game_id)+"/iip/false/ubt/am/isp/false"
+                            yield Request(url=url, callback=self.parse_each, dont_filter=True, meta={'pt': pt})
+                        if pt == "1":
+                            url = "https://odata.jiushan6688.com/odds6i/d/getamodds/zh-cn/eid/"+str(game_id)+"/iip/false/ubt/am/isp/false"
+                            yield Request(url=url, callback=self.parse_each, dont_filter=True, meta={'pt': pt})
+    #
     def parse_each(self, response):
         if response.status == 200:
             # 球队进球数 大小

+ 0 - 0
hg3535/utils/__init__.py


+ 23 - 0
hg3535/utils/helper.py

@@ -0,0 +1,23 @@
+import hashlib
+import json
+import requests
+from requests_futures.sessions import FuturesSession
+
+
+class Helper(object):
+    @staticmethod
+    def async_post(url, params):
+        try:
+            fs_session = FuturesSession()
+            data = fs_session.post(url, data={"data": json.dumps(params), "token": "02S0wW15643928255d3ebd790ce04"}, timeout=30).result()
+            if data:
+                return data.content.decode('utf-8')
+        except requests.exceptions.RequestException as e:
+            print(e)
+
+    @staticmethod
+    def genearte_MD5(params):
+        # 创建md5对象
+        hl = hashlib.md5()
+        hl.update(params.encode(encoding='utf-8'))
+        return hl.hexdigest()

Some files were not shown because too many files changed in this diff