Your Name 6 anni fa
parent
commit
22dc1c61ef

+ 2 - 1
hg3535/.idea/hg3535.iml

@@ -4,8 +4,9 @@
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/spiders" isTestSource="false" />
+      <excludeFolder url="file://$MODULE_DIR$/venv" />
     </content>
-    <orderEntry type="inheritedJdk" />
+    <orderEntry type="jdk" jdkName="Python 3.7 (venv)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="R User Library" level="project" />
     <orderEntry type="library" name="R Skeletons" level="application" />

+ 1 - 0
hg3535/.idea/inspectionProfiles/Project_Default.xml

@@ -1,6 +1,7 @@
 <component name="InspectionProjectProfileManager">
   <profile version="1.0">
     <option name="myName" value="Project Default" />
+    <inspection_tool class="PyInterpreterInspection" enabled="false" level="WARNING" enabled_by_default="false" />
     <inspection_tool class="PyPackageRequirementsInspection" enabled="false" level="WARNING" enabled_by_default="false">
       <option name="ignoredPackages">
         <value>

+ 1 - 1
hg3535/.idea/misc.xml

@@ -3,5 +3,5 @@
   <component name="JavaScriptSettings">
     <option name="languageLevel" value="ES6" />
   </component>
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (venv)" project-jdk-type="Python SDK" />
 </project>

+ 234 - 221
hg3535/.idea/workspace.xml

@@ -1,32 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="7fa42e97-ddea-4404-91db-5a9ccc162649" name="Default Changelist" comment="updata">
-      <change beforePath="$PROJECT_DIR$/../.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../.idea/workspace.xml" afterDir="false" />
+    <list default="true" id="7fa42e97-ddea-4404-91db-5a9ccc162649" name="Default Changelist" comment="">
+      <change beforePath="$PROJECT_DIR$/.idea/hg3535.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/hg3535.iml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/items.py" beforeDir="false" afterPath="$PROJECT_DIR$/items.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/pipeline/bangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/bangqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/pipeline/lanqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/lanqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/pipeline/roll_lanqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/roll_lanqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/pipeline/roll_wangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/roll_wangqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/pipeline/roll_zuqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/roll_zuqiu.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/pipeline/wangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/wangqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/pipeline/zuqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/pipeline/zuqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/settings.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/spiders/bangqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/bangqiu.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/spiders/bq_jieshu.py" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/spiders/lanqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/lanqiu.py" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/spiders/lq_jieshu.py" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/spiders/guanjun.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/guanjun.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" />
-      <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" />
-      <change beforePath="$PROJECT_DIR$/spiders/zuqiu.py" beforeDir="false" afterPath="$PROJECT_DIR$/spiders/zuqiu.py" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/utils/helper.py" beforeDir="false" afterPath="$PROJECT_DIR$/utils/helper.py" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -37,7 +26,7 @@
   </component>
   <component name="CoverageDataManager">
     <SUITE FILE_PATH="coverage/hg3535$items.coverage" NAME="items Coverage Results" MODIFIED="1554291398794" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
-    <SUITE FILE_PATH="coverage/hg3535$main.coverage" NAME="main Coverage Results" MODIFIED="1566886233881" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
+    <SUITE FILE_PATH="coverage/hg3535$main.coverage" NAME="main Coverage Results" MODIFIED="1567145027030" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
     <SUITE FILE_PATH="coverage/hg3535$hgjieshu.coverage" NAME="hgjieshu Coverage Results" MODIFIED="1558494720094" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/spiders" />
     <SUITE FILE_PATH="coverage/hg3535$halffull.coverage" NAME="halffull Coverage Results" MODIFIED="1554544334424" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/spiders" />
     <SUITE FILE_PATH="coverage/hg3535$pipelines.coverage" NAME="pipelines Coverage Results" MODIFIED="1554290866137" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
@@ -68,53 +57,50 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/main.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="198">
-              <caret line="13" column="41" selection-start-line="13" selection-start-column="41" selection-end-line="13" selection-end-column="41" />
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/settings.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="-2584">
-              <caret line="31" column="21" selection-start-line="31" selection-start-column="21" selection-end-line="31" selection-end-column="21" />
+            <state relative-caret-position="140">
+              <caret line="7" column="33" selection-start-line="7" selection-start-column="31" selection-end-line="7" selection-end-column="36" />
+              <folding>
+                <element signature="e#0#10#0" expanded="true" />
+              </folding>
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/middlewares.py">
+        <entry file="file://$PROJECT_DIR$/pipeline/lanqiu.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="259">
-              <caret line="134" selection-start-line="134" selection-end-line="134" />
+            <state relative-caret-position="681">
+              <caret line="238" column="21" selection-start-line="238" selection-start-column="21" selection-end-line="238" selection-end-column="21" />
+              <folding>
+                <element signature="e#0#15#0" expanded="true" />
+              </folding>
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/pipelines.py">
+        <entry file="file://$PROJECT_DIR$/settings.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="691">
-              <caret line="1294" column="17" selection-start-line="1294" selection-start-column="17" selection-end-line="1294" selection-end-column="17" />
+            <state relative-caret-position="176">
+              <caret line="149" column="9" selection-start-line="149" selection-end-line="149" selection-end-column="12" />
             </state>
           </provider>
         </entry>
       </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/spiders/zuqiu.py">
+      <file pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="468">
-              <caret line="38" selection-start-line="38" selection-end-line="38" />
+            <state relative-caret-position="140">
+              <caret line="7" column="33" lean-forward="true" selection-start-line="7" selection-start-column="33" selection-end-line="7" selection-end-column="33" />
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
+        <entry file="file://$PROJECT_DIR$/utils/helper.py">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="12024">
-              <caret line="683" column="137" selection-start-line="683" selection-start-column="137" selection-end-line="683" selection-end-column="137" />
+            <state relative-caret-position="220">
+              <caret line="11" column="113" selection-start-line="11" selection-start-column="113" selection-end-line="11" selection-end-column="113" />
               <folding>
                 <element signature="e#0#14#0" expanded="true" />
               </folding>
@@ -122,15 +108,6 @@
           </provider>
         </entry>
       </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/utils/helper.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="144">
-              <caret line="11" column="97" selection-start-line="11" selection-start-column="84" selection-end-line="11" selection-end-column="113" />
-            </state>
-          </provider>
-        </entry>
-      </file>
     </leaf>
   </component>
   <component name="FileTemplateManagerImpl">
@@ -142,7 +119,6 @@
   </component>
   <component name="FindInProjectRecents">
     <findStrings>
-      <find>match_id</find>
       <find>half_concede_home</find>
       <find>conn</find>
       <find>result</find>
@@ -172,9 +148,11 @@
       <find>lastnumber_dict</find>
       <find>last_numbers_dict</find>
       <find>capots_dict</find>
+      <find>self.session</find>
     </findStrings>
     <replaceStrings>
       <replace>&quot;&quot;</replace>
+      <replace>session</replace>
     </replaceStrings>
   </component>
   <component name="Git.Settings">
@@ -222,7 +200,6 @@
   <component name="IdeDocumentHistory">
     <option name="CHANGED_PATHS">
       <list>
-        <option value="$PROJECT_DIR$/log/zuqiu_log.log" />
         <option value="$PROJECT_DIR$/log/ball_status.log" />
         <option value="$PROJECT_DIR$/log/bangqiu.log" />
         <option value="$PROJECT_DIR$/log/guanjun.log" />
@@ -254,33 +231,34 @@
         <option value="$PROJECT_DIR$/spiders/liansai.py" />
         <option value="$PROJECT_DIR$/ball_func.py" />
         <option value="$PROJECT_DIR$/spiders/bangqiu.py" />
-        <option value="$PROJECT_DIR$/spiders/roll_bangqiu.py" />
         <option value="$PROJECT_DIR$/spiders/zq_jieshu.py" />
         <option value="$PROJECT_DIR$/pipelines.py" />
-        <option value="$PROJECT_DIR$/spiders/roll_wangqiu.py" />
         <option value="$PROJECT_DIR$/.gitignore" />
-        <option value="$PROJECT_DIR$/spiders/guanjun.py" />
         <option value="$PROJECT_DIR$/pipeline/ball_func.py" />
         <option value="$PROJECT_DIR$/pipeline/guanjun.py" />
         <option value="$PROJECT_DIR$/spiders/zuqiu.py" />
+        <option value="$PROJECT_DIR$/spiders/lanqiu.py" />
+        <option value="$PROJECT_DIR$/pipeline/roll_bangqiu.py" />
+        <option value="$PROJECT_DIR$/spiders/guanjun.py" />
+        <option value="$PROJECT_DIR$/spiders/roll_bangqiu.py" />
+        <option value="$PROJECT_DIR$/spiders/roll_wangqiu.py" />
+        <option value="$PROJECT_DIR$/pipeline/roll_wangqiu.py" />
+        <option value="$PROJECT_DIR$/pipeline/roll_lanqiu.py" />
         <option value="$PROJECT_DIR$/spiders/roll_zuqiu.py" />
         <option value="$PROJECT_DIR$/pipeline/roll_zuqiu.py" />
-        <option value="$PROJECT_DIR$/spiders/lanqiu.py" />
+        <option value="$PROJECT_DIR$/main.py" />
         <option value="$PROJECT_DIR$/pipeline/lanqiu.py" />
-        <option value="$PROJECT_DIR$/pipeline/roll_wangqiu.py" />
-        <option value="$PROJECT_DIR$/pipeline/roll_bangqiu.py" />
+        <option value="$PROJECT_DIR$/settings.py" />
         <option value="$PROJECT_DIR$/utils/helper.py" />
-        <option value="$PROJECT_DIR$/main.py" />
         <option value="$PROJECT_DIR$/pipeline/zuqiu.py" />
-        <option value="$PROJECT_DIR$/settings.py" />
       </list>
     </option>
   </component>
   <component name="ProjectFrameBounds" extendedState="6">
-    <option name="x" value="-8" />
-    <option name="y" value="-8" />
+    <option name="x" value="-20" />
+    <option name="y" value="46" />
     <option name="width" value="1936" />
-    <option name="height" value="1066" />
+    <option name="height" value="1030" />
   </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
   <component name="ProjectView">
@@ -288,7 +266,6 @@
       <foldersAlwaysOnTop value="true" />
     </navigator>
     <panes>
-      <pane id="Scope" />
       <pane id="ProjectPane">
         <subPane>
           <expand>
@@ -301,33 +278,20 @@
               <item name="hg3535" type="462c0819:PsiDirectoryNode" />
               <item name="pipeline" 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="hg3535" type="462c0819:PsiDirectoryNode" />
-              <item name="utils" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="hg3535" type="b2602c69:ProjectViewProjectNode" />
-              <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
-            </path>
           </expand>
           <select />
         </subPane>
       </pane>
+      <pane id="Scope" />
     </panes>
   </component>
   <component name="PropertiesComponent">
     <property name="WebServerToolWindowFactoryState" value="false" />
     <property name="add_unversioned_files" value="$PROJECT_DIR$/.gitignore" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/../../sports_collect" />
+    <property name="last_opened_file_path" value="C:/venv" />
     <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" />
+    <property name="settings.editor.selected.configurable" value="editor.preferences.fonts.default" />
   </component>
   <component name="RecentsManager">
     <key name="MoveFile.RECENT_KEYS">
@@ -353,7 +317,7 @@
     </option>
   </component>
   <component name="RunManager" selected="Python.main">
-    <configuration name="halffull" type="PythonConfigurationType" factoryName="Python" temporary="true">
+    <configuration name="hgjieshu" type="PythonConfigurationType" factoryName="Python" temporary="true">
       <module name="hg3535" />
       <option name="INTERPRETER_OPTIONS" value="" />
       <option name="PARENT_ENVS" value="true" />
@@ -366,7 +330,7 @@
       <option name="ADD_CONTENT_ROOTS" value="true" />
       <option name="ADD_SOURCE_ROOTS" value="true" />
       <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
-      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/spiders/halffull.py" />
+      <option name="SCRIPT_NAME" value="C:\Users\admin\Desktop\sports_scrapy\hg3535\spiders\zq_jieshu.py" />
       <option name="PARAMETERS" value="" />
       <option name="SHOW_COMMAND_LINE" value="false" />
       <option name="EMULATE_TERMINAL" value="false" />
@@ -375,7 +339,7 @@
       <option name="INPUT_FILE" value="" />
       <method v="2" />
     </configuration>
-    <configuration name="hgjieshu" type="PythonConfigurationType" factoryName="Python" temporary="true">
+    <configuration name="liansai" type="PythonConfigurationType" factoryName="Python" temporary="true">
       <module name="hg3535" />
       <option name="INTERPRETER_OPTIONS" value="" />
       <option name="PARENT_ENVS" value="true" />
@@ -388,7 +352,7 @@
       <option name="ADD_CONTENT_ROOTS" value="true" />
       <option name="ADD_SOURCE_ROOTS" value="true" />
       <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
-      <option name="SCRIPT_NAME" value="C:\Users\admin\Desktop\sports_scrapy\hg3535\spiders\zq_jieshu.py" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/spiders/liansai.py" />
       <option name="PARAMETERS" value="" />
       <option name="SHOW_COMMAND_LINE" value="false" />
       <option name="EMULATE_TERMINAL" value="false" />
@@ -397,7 +361,7 @@
       <option name="INPUT_FILE" value="" />
       <method v="2" />
     </configuration>
-    <configuration name="liansai" type="PythonConfigurationType" factoryName="Python" temporary="true">
+    <configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
       <module name="hg3535" />
       <option name="INTERPRETER_OPTIONS" value="" />
       <option name="PARENT_ENVS" value="true" />
@@ -405,12 +369,12 @@
         <env name="PYTHONUNBUFFERED" value="1" />
       </envs>
       <option name="SDK_HOME" value="" />
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/spiders" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
       <option name="IS_MODULE_SDK" value="true" />
       <option name="ADD_CONTENT_ROOTS" value="true" />
       <option name="ADD_SOURCE_ROOTS" value="true" />
       <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
-      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/spiders/liansai.py" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
       <option name="PARAMETERS" value="" />
       <option name="SHOW_COMMAND_LINE" value="false" />
       <option name="EMULATE_TERMINAL" value="false" />
@@ -419,7 +383,7 @@
       <option name="INPUT_FILE" value="" />
       <method v="2" />
     </configuration>
-    <configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
+    <configuration name="wangqiu" type="PythonConfigurationType" factoryName="Python" temporary="true">
       <module name="hg3535" />
       <option name="INTERPRETER_OPTIONS" value="" />
       <option name="PARENT_ENVS" value="true" />
@@ -427,12 +391,12 @@
         <env name="PYTHONUNBUFFERED" value="1" />
       </envs>
       <option name="SDK_HOME" value="" />
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/spiders" />
       <option name="IS_MODULE_SDK" value="true" />
       <option name="ADD_CONTENT_ROOTS" value="true" />
       <option name="ADD_SOURCE_ROOTS" value="true" />
       <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
-      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/spiders/wangqiu.py" />
       <option name="PARAMETERS" value="" />
       <option name="SHOW_COMMAND_LINE" value="false" />
       <option name="EMULATE_TERMINAL" value="false" />
@@ -441,7 +405,7 @@
       <option name="INPUT_FILE" value="" />
       <method v="2" />
     </configuration>
-    <configuration name="wangqiu" type="PythonConfigurationType" factoryName="Python" temporary="true">
+    <configuration name="zuqiu" type="PythonConfigurationType" factoryName="Python" temporary="true">
       <module name="hg3535" />
       <option name="INTERPRETER_OPTIONS" value="" />
       <option name="PARENT_ENVS" value="true" />
@@ -454,7 +418,7 @@
       <option name="ADD_CONTENT_ROOTS" value="true" />
       <option name="ADD_SOURCE_ROOTS" value="true" />
       <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
-      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/spiders/wangqiu.py" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/spiders/zuqiu.py" />
       <option name="PARAMETERS" value="" />
       <option name="SHOW_COMMAND_LINE" value="false" />
       <option name="EMULATE_TERMINAL" value="false" />
@@ -466,10 +430,10 @@
     <recent_temporary>
       <list>
         <item itemvalue="Python.main" />
+        <item itemvalue="Python.zuqiu" />
         <item itemvalue="Python.wangqiu" />
         <item itemvalue="Python.liansai" />
         <item itemvalue="Python.hgjieshu" />
-        <item itemvalue="Python.halffull" />
       </list>
     </recent_temporary>
   </component>
@@ -584,7 +548,11 @@
       <workItem from="1565574821845" duration="1238000" />
       <workItem from="1566802827516" duration="684000" />
       <workItem from="1566871828920" duration="61000" />
-      <workItem from="1566872141146" duration="9146000" />
+      <workItem from="1566872141146" duration="14544000" />
+      <workItem from="1566976369645" duration="4000" />
+      <workItem from="1566976385269" duration="13184000" />
+      <workItem from="1566990066292" duration="35762000" />
+      <workItem from="1567126891838" duration="15410000" />
     </task>
     <task id="LOCAL-00001" summary="修改后,版本二">
       <created>1555727493584</created>
@@ -789,11 +757,18 @@
       <option name="project" value="LOCAL" />
       <updated>1564470453693</updated>
     </task>
-    <option name="localTasksCounter" value="30" />
+    <task id="LOCAL-00030" summary="updata">
+      <created>1566886504744</created>
+      <option name="number" value="00030" />
+      <option name="presentableId" value="LOCAL-00030" />
+      <option name="project" value="LOCAL" />
+      <updated>1566886504744</updated>
+    </task>
+    <option name="localTasksCounter" value="31" />
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="1624326000" />
+    <option name="totallyTimeSpent" value="1694084000" />
   </component>
   <component name="TodoView">
     <todo-panel id="selected-file">
@@ -807,22 +782,22 @@
   <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.15191898" />
+      <window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.71173847" visible="true" weight="0.15831557" />
       <window_info id="Structure" order="1" sideWeight="0.2882615" side_tool="true" weight="0.1108742" />
       <window_info id="Favorites" order="2" sideWeight="0.5013405" side_tool="true" weight="0.108208954" />
       <window_info anchor="bottom" id="Message" order="0" />
       <window_info anchor="bottom" id="Find" order="1" weight="0.32832617" />
-      <window_info anchor="bottom" id="Debug" order="2" sideWeight="0.49946696" weight="0.37982833" />
+      <window_info anchor="bottom" id="Debug" order="2" sideWeight="0.49946696" visible="true" weight="0.34656653" />
       <window_info anchor="bottom" id="Cvs" order="3" weight="0.25" />
       <window_info anchor="bottom" id="Inspection" order="4" weight="0.4" />
       <window_info anchor="bottom" id="TODO" order="5" weight="0.32832617" />
       <window_info anchor="bottom" id="Docker" order="6" show_stripe_button="false" />
       <window_info anchor="bottom" id="Version Control" order="7" weight="0.1555794" />
       <window_info anchor="bottom" id="Database Changes" order="8" />
-      <window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50692964" side_tool="true" weight="0.3858521" />
-      <window_info anchor="bottom" x="22" y="376" width="1876" height="298" id="Terminal" order="10" sideWeight="0.49307036" weight="0.444206" />
+      <window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50692964" side_tool="true" weight="0.38519314" />
+      <window_info anchor="bottom" x="22" y="376" width="1876" height="298" id="Terminal" order="10" sideWeight="0.49307036" weight="0.3530043" />
       <window_info anchor="bottom" id="Python Console" order="11" sideWeight="0.49946696" weight="0.4356223" />
-      <window_info active="true" anchor="bottom" id="Run" order="12" sideWeight="0.87473345" visible="true" weight="0.6051502" />
+      <window_info anchor="bottom" id="Run" order="12" sideWeight="0.87473345" weight="0.34978542" />
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -830,6 +805,7 @@
       <window_info anchor="right" id="Database" order="4" weight="0.32995737" />
       <window_info anchor="right" id="R Packages" order="5" weight="0.32889125" />
       <window_info anchor="right" id="R Graphics" order="6" weight="0.32995737" />
+      <window_info anchor="right" id="Coverage" order="7" side_tool="true" />
     </layout>
     <layout-to-restore>
       <window_info content_ui="combo" id="Project" order="0" sideWeight="0.71173847" visible="true" weight="0.13539445" />
@@ -936,14 +912,29 @@
           <option name="timeStamp" value="4" />
         </line-breakpoint>
         <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
-          <url>file://$PROJECT_DIR$/spiders/zuqiu.py</url>
-          <line>38</line>
-          <option name="timeStamp" value="9" />
+          <url>file://$PROJECT_DIR$/pipeline/zuqiu.py</url>
+          <line>68</line>
+          <option name="timeStamp" value="29" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/pipeline/lanqiu.py</url>
+          <line>254</line>
+          <option name="timeStamp" value="37" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/pipeline/lanqiu.py</url>
+          <line>253</line>
+          <option name="timeStamp" value="38" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/pipeline/lanqiu.py</url>
+          <line>236</line>
+          <option name="timeStamp" value="40" />
         </line-breakpoint>
         <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
-          <url>file://$PROJECT_DIR$/spiders/zuqiu.py</url>
-          <line>64</line>
-          <option name="timeStamp" value="10" />
+          <url>file://$PROJECT_DIR$/pipeline/lanqiu.py</url>
+          <line>237</line>
+          <option name="timeStamp" value="41" />
         </line-breakpoint>
       </breakpoints>
       <default-breakpoints>
@@ -972,40 +963,6 @@
     </expressions>
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/log/zq_jieshu_2019_5_27.log" />
-    <entry file="file://$PROJECT_DIR$/spiders/bq_jieshu.py" />
-    <entry file="file://$PROJECT_DIR$/spiders/lq_jieshu.py" />
-    <entry file="file://$PROJECT_DIR$/spiders/liansai.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="209">
-          <caret line="49" column="53" lean-forward="true" selection-start-line="49" selection-start-column="53" selection-end-line="49" selection-end-column="53" />
-          <folding>
-            <element signature="e#24#39#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/_strptime.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="151">
-          <caret line="325" selection-start-line="325" selection-end-line="325" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/scrapy/middleware.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="172">
-          <caret line="64" selection-start-line="64" selection-end-line="64" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/scrapy/pipelines/__init__.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="396">
-          <caret line="23" selection-start-line="23" selection-end-line="23" />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/scrapy/core/scraper.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="159">
@@ -1020,16 +977,6 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/roll_lanqiu.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-3480">
-          <caret line="37" column="14" selection-start-line="37" selection-start-column="12" selection-end-line="37" selection-end-column="23" />
-          <folding>
-            <element signature="e#24#39#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/twisted/internet/defer.py">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="11484">
@@ -1146,180 +1093,246 @@
         <state relative-caret-position="-1152" />
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/roll_zuqiu.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/bangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="3708">
-          <caret line="211" column="57" selection-start-line="211" selection-start-column="57" selection-end-line="211" selection-end-column="57" />
+        <state relative-caret-position="-5382">
+          <folding>
+            <element signature="e#0#15#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/roll_zuqiu.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/ball_func.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="4038">
-          <caret line="434" column="48" selection-start-line="434" selection-start-column="48" selection-end-line="434" selection-end-column="48" />
+        <state relative-caret-position="342">
+          <caret line="30" column="9" lean-forward="true" selection-start-line="30" selection-start-column="9" selection-end-line="30" selection-end-column="9" />
+          <folding>
+            <element signature="e#0#15#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/lanqiu.py">
+    <entry file="file://$PROJECT_DIR$/spiders/wangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="162">
-          <caret line="356" column="17" selection-start-line="356" selection-start-column="11" selection-end-line="356" selection-end-column="22" />
+        <state relative-caret-position="-3024">
+          <caret line="14" column="20" selection-start-line="14" selection-start-column="20" selection-end-line="14" selection-end-column="20" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/lanqiu.py">
+    <entry file="file://$PROJECT_DIR$/pipelines.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="3">
-          <caret line="513" column="35" selection-start-line="513" selection-start-column="24" selection-end-line="513" selection-end-column="35" />
-          <folding>
-            <element signature="e#24#35#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="2797">
+          <caret line="1294" column="17" selection-start-line="1294" selection-start-column="17" selection-end-line="1294" selection-end-column="17" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/bangqiu.py">
+    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/aiohttp/client.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-5382">
+        <state relative-caret-position="166">
+          <caret line="574" selection-start-line="574" selection-end-line="574" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/pymongo/pool.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="1215">
+          <caret line="614" selection-start-line="614" selection-end-line="614" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python36/Lib/site-packages/twisted/python/util.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="413">
+          <caret line="630" selection-start-line="630" selection-end-line="630" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pipeline/roll_bangqiu.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="1206">
+          <caret line="76" column="39" selection-start-line="76" selection-start-column="39" selection-end-line="76" selection-end-column="39" />
           <folding>
             <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/roll_bangqiu.py">
+    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/asyncio/base_events.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-1094">
-          <caret line="175" lean-forward="true" selection-start-line="175" selection-end-line="175" />
-          <folding>
-            <element signature="e#46#61#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="187">
+          <caret line="520" selection-start-line="520" selection-end-line="520" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/ball_func.py">
+    <entry file="file://$PROJECT_DIR$/spiders/roll_lanqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="342">
-          <caret line="30" column="9" lean-forward="true" selection-start-line="30" selection-start-column="9" selection-end-line="30" selection-end-column="9" />
+        <state relative-caret-position="540">
+          <caret line="36" column="22" selection-start-line="36" selection-start-column="19" selection-end-line="36" selection-end-column="32" />
           <folding>
-            <element signature="e#0#15#0" expanded="true" />
+            <element signature="e#24#39#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/wangqiu.py">
+    <entry file="file://$PROJECT_DIR$/spiders/roll_bangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-3024">
-          <caret line="14" column="20" selection-start-line="14" selection-start-column="20" selection-end-line="14" selection-end-column="20" />
+        <state relative-caret-position="90">
+          <caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/pipeline/wangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-4896">
+        <state relative-caret-position="-54">
           <folding>
             <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
+    <entry file="file://$PROJECT_DIR$/middlewares.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="667">
+          <caret line="152" selection-start-line="152" selection-end-line="152" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/asyncio/tasks.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="145">
+          <caret line="349" selection-start-line="349" selection-end-line="349" />
+        </state>
+      </provider>
+    </entry>
     <entry file="file://$PROJECT_DIR$/spiders/guanjun.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-252">
-          <caret line="10" selection-start-line="10" selection-end-line="10" />
+        <state relative-caret-position="-610">
+          <caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pipeline/roll_wangqiu.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="216">
+          <caret line="165" column="55" selection-start-line="165" selection-start-column="55" selection-end-line="165" selection-end-column="55" />
           <folding>
-            <element signature="e#38#53#0" expanded="true" />
+            <element signature="e#0#15#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/spiders/roll_wangqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-3204">
-          <caret line="64" selection-start-line="64" selection-end-line="64" />
-          <folding>
-            <element signature="e#24#39#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="90">
+          <caret line="5" column="13" lean-forward="true" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/roll_bangqiu.py">
+    <entry file="file://$PROJECT_DIR$/spiders/zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="1206">
-          <caret line="76" column="39" selection-start-line="76" selection-start-column="39" selection-end-line="76" selection-end-column="39" />
+        <state relative-caret-position="548">
+          <caret line="66" selection-start-line="66" selection-end-line="66" />
           <folding>
-            <element signature="e#0#15#0" expanded="true" />
+            <element signature="e#24#35#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/roll_wangqiu.py">
+    <entry file="file://C:/venv/Lib/site-packages/twisted/internet/task.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="195">
+          <caret line="630" selection-start-line="630" selection-end-line="630" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://C:/venv/Lib/site-packages/pymongo/mongo_client.py">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="-16140">
+          <caret line="95" column="8" selection-start-line="95" selection-start-column="8" selection-end-line="95" selection-end-column="8" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/spiders/roll_zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="1171">
-          <caret line="88" selection-start-line="88" selection-end-line="100" selection-end-column="56" />
+        <state relative-caret-position="298">
+          <caret line="32" column="17" lean-forward="true" selection-start-line="32" selection-start-column="17" selection-end-line="32" selection-end-column="17" />
           <folding>
-            <element signature="e#0#15#0" expanded="true" />
+            <element signature="e#24#35#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/pipeline/roll_lanqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state>
+        <state relative-caret-position="1297">
+          <caret line="317" column="38" selection-start-line="317" selection-start-column="38" selection-end-line="317" selection-end-column="38" />
           <folding>
             <element signature="e#0#14#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/middlewares.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/roll_zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="259">
-          <caret line="134" selection-start-line="134" selection-end-line="134" />
+        <state relative-caret-position="739">
+          <caret line="43" column="37" selection-start-line="43" selection-start-column="37" selection-end-line="43" selection-end-column="37" />
+          <folding>
+            <element signature="e#18#33#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipelines.py">
+    <entry file="file://$PROJECT_DIR$/spiders/lanqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="691">
-          <caret line="1294" column="17" selection-start-line="1294" selection-start-column="17" selection-end-line="1294" selection-end-column="17" />
+        <state relative-caret-position="8310">
+          <caret line="513" column="35" selection-start-line="513" selection-start-column="24" selection-end-line="513" selection-end-column="35" />
+          <folding>
+            <element signature="e#24#35#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/spiders/zuqiu.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/lanqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="468">
-          <caret line="38" selection-start-line="38" selection-end-line="38" />
+        <state relative-caret-position="681">
+          <caret line="238" column="21" selection-start-line="238" selection-start-column="21" selection-end-line="238" selection-end-column="21" />
+          <folding>
+            <element signature="e#0#15#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/utils/helper.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="144">
-          <caret line="11" column="97" selection-start-line="11" selection-start-column="84" selection-end-line="11" selection-end-column="113" />
+        <state relative-caret-position="220">
+          <caret line="11" column="113" selection-start-line="11" selection-start-column="113" selection-end-line="11" selection-end-column="113" />
+          <folding>
+            <element signature="e#0#14#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="198">
-          <caret line="13" column="41" selection-start-line="13" selection-start-column="41" selection-end-line="13" selection-end-column="41" />
+        <state relative-caret-position="140">
+          <caret line="7" column="33" selection-start-line="7" selection-start-column="31" selection-end-line="7" selection-end-column="36" />
+          <folding>
+            <element signature="e#0#10#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
+    <entry file="file://$PROJECT_DIR$/settings.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="12024">
-          <caret line="683" column="137" selection-start-line="683" selection-start-column="137" selection-end-line="683" selection-end-column="137" />
-          <folding>
-            <element signature="e#0#14#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="176">
+          <caret line="149" column="9" selection-start-line="149" selection-end-line="149" selection-end-column="12" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/settings.py">
+    <entry file="file://$PROJECT_DIR$/pipeline/zuqiu.py">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-2584">
-          <caret line="31" column="21" selection-start-line="31" selection-start-column="21" selection-end-line="31" selection-end-column="21" />
+        <state relative-caret-position="140">
+          <caret line="7" column="33" lean-forward="true" selection-start-line="7" selection-start-column="33" selection-end-line="7" selection-end-column="33" />
         </state>
       </provider>
     </entry>

+ 2 - 2
hg3535/main.py

@@ -5,8 +5,8 @@ from scrapy.cmdline import execute
 # print(os.path.dirname(os.path.abspath(__file__)))
 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", "zuqiu"])
+execute(["scrapy", "crawl", "lanqiu"])
 # execute(["scrapy", "crawl", "guanjun"])
 # execute(["scrapy", "crawl", "wangqiu"])
 # execute(["scrapy", "crawl", "wqbodan"])

+ 109 - 193
hg3535/pipeline/lanqiu.py

@@ -1,29 +1,32 @@
 import datetime
-import json
 import pymongo
 import time
 import logging
-import requests
+from twisted.internet import defer, reactor
+
+import settings
 from .ball_func import fuhao
 
 from ..utils.helper import Helper
-from .ball_func import get_pcode, new_time, out_time
-from concurrent.futures import ThreadPoolExecutor
-from requests_futures.sessions import FuturesSession
+from .ball_func import new_time
+
 
 
 class 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']
-        self.session = FuturesSession(executor=ThreadPoolExecutor(max_workers=10))
+        self.mongo = pymongo.MongoClient(host=settings.M_HOST, username=settings.M_USER, password=settings.M_PASSWORD, port=settings.M_POST)
+        self.db = self.mongo[settings.M_DB]
 
+    @defer.inlineCallbacks
     def process_item(self, item, spider):
-        # 使用twisted将mysql插入变成异步执行
-        lq_odds = []
-        url = 'http://admin.5gogo.com'
+        # out = defer.Deferred()
+        # reactor.callInThread(self._do_calculation, item, out)
+        # yield out
+        # defer.returnValue(item)
+        self._do_calculation(item, 'out')
+
+    def _do_calculation(self, item, out):
         logger = logging.getLogger(__name__)
-        # # logger.warning(query.addErrback(self.handle_error, item, spider))
         # 联赛id
         league_id = item['league_id']
         # 联赛名
@@ -40,7 +43,6 @@ class Lanqiupipeline(object):
         # 比赛状态
         zhuangtai = item['zhuangtai']
         # 日期
-        # data_game = item['data_game']
         try:
             data_game = item['data_game'].split("/")
             month = str(data_game[1].strip())
@@ -87,110 +89,43 @@ class Lanqiupipeline(object):
         team_scores_dict = item['team_score']
         team_scores_dict_rule = item['team_score_rule']
         # 让球
-        lanqiu = item['lanqiu']
+        # lanqiu = item['lanqiu']
         match_date, match_time, time3 = new_time(us_time)
-        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+        uuid = Helper.genearte_uuid(league_name + 'hg3535')
         # 让球 数据插入数据库
         """联赛"""
-        last_time = '2019-12-31 23:59:59'
-        league_dict = {"game_code": "lq", "title": "league", "source": "hg3535"}
-        league_list = []
-
-        league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
-        league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
-        league_data = dict(zip(league_key, league_value))
-        league_list.append(league_data)
-        league_dict['data'] = league_list
-        # print(league_list)
-        # print(league_dict)
+        last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
         if self.db.hg3535_lq_league.find({'lg_id': league_id}).count() < 1:
-            res = Helper.async_post(url + '/setLeague', league_dict)
-            print(res)
-            self.db.hg3535_lq_league.insert(league_list)
-
+            league_dict = {"game_code": "lq", "title": "league", "source": "hg3535"}
+            league_list = []
+            league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
+            league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
+            league_data = dict(zip(league_key, league_value))
+            league_list.append(league_data)
+            league_dict['data'] = league_list
+            response_data = Helper.async_post(settings.LEAGUE_URL, league_dict)
+            if "成功" in response_data:
+                self.db.zq_league35.insert(league_list)
         """赛事"""
-        competition = self.db.hg3535_lq_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": "lq", "title": "match", "source": "hg3535"}
-                    match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                                 "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                                 "half_match_id", "is_today", 'pt']
-                    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, pt]
-                    match_data = dict(zip(match_key, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_lq_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": "lq", "title": "match", "source": "hg3535"}
-                    match_key = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
-                                 "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
-                                 "half_match_id", "is_today", 'pt']
-                    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, pt]
-                    match_data = dict(zip(match_key, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_lq_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": "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", 'pt']
-                    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, pt]
-                    match_data = dict(zip(match_kay, match_value))
-                    match_list.append(match_data)
-                    match_dict['data'] = match_list
-                    # print(match_list)
-                    # print(match_dict)
-                    res = Helper.async_post(url + '/setMatch', match_dict)
-                    print(res)
-                    self.db.hg3535_lq_competition.update({'match_id': str(match_id)},
-                                                         {"$set": {"is_today": 1, 'match_time': match_time}},
-                                                         upsert=True)
-            else:
-                print("赛事已存在,赛事状态时间未改变,不做修改")
+        if pt == 3:
+            is_rollball = 0
+            is_today = 0
+            is_morningplate = 0
+            is_stringscene = 1
+        elif pt == 2:
+            is_rollball = 0
+            is_today = 0
+            is_morningplate = 1
+            is_stringscene = 0
         else:
-            print('赛事不存在,插入新赛事')
-            if pt == 3:
-                is_rollball = 0
-                is_today = 0
-                is_morningplate = 0
-                is_stringscene = 1
-            elif pt == 2:
-                is_rollball = 0
-                is_today = 0
-                is_morningplate = 1
-                is_stringscene = 0
-            else:
-                is_today = 1
-                is_rollball = 0
-                is_morningplate = 0
-                is_stringscene = 0
+            is_today = 1
+            is_rollball = 0
+            is_morningplate = 0
+            is_stringscene = 0
+        pt_dict = {'1': 'is_today', '2': 'is_morningplate', '3': 'is_stringscene', '4': 'is_rollball'}
+        pt_status = pt_dict[str(pt)]
+        if self.db.lq_competition35.find({'match_id': match_id, pt_status: 1}).count() < 1:
+            match_list = []
             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",
@@ -200,17 +135,11 @@ class Lanqiupipeline(object):
             match_data = dict(zip(match_kay, match_value))
             match_list.append(match_data)
             match_dict['data'] = match_list
-            res = Helper.async_post(url + '/setMatch', match_dict)
-            print(res)
-            self.db.hg3535_lq_competition.insert(match_list)
+            response_data = Helper.async_post(settings.MATCH_URL, match_dict)
+            if "成功" in response_data:
+                self.db.lq_competition35.insert(match_data)
 
         """赔率"""
-        try:
-            result = self.db.hg3535_lq_odds.find_one({'match_id': str(match_id), 'pt': pt})
-            odds_only_list = result['odds_only']
-        except:
-            result = ''
-            odds_only_list = []
         data_list = []
         odds_onlys = []
         # 让球
@@ -219,155 +148,142 @@ class Lanqiupipeline(object):
                 if value:
                     for index, concedes_value in enumerate(value):
                         sole_str = 'CO' + str(index) + str(match_id) + 'hg3535'
-                        sole = Helper.genearte_MD5(sole_str)
+                        sole = Helper.genearte_MD5(sole_str, pt)
                         odds_str = 'CO' + str(index) + str(match_id) + 'hg3535' + str(
                             concedes_dict_rule[key][index]) + str(concedes_value)
-                        odds_only = Helper.genearte_MD5(odds_str)
+                        odds_only = Helper.genearte_MD5(odds_str, pt)
                         condition = fuhao(str(concedes_dict_rule[key][index]))
                         concedes_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                              "condition", "odds_only", "sole", "source", "type", "team"]
                         concedes_dict_value = [match_id, league_id, key, '0', index, 'CO', concedes_value, condition,
                                                odds_only, sole, 'hg3535', '0', '']
                         concedes_dict_data = dict(zip(concedes_dict_key, concedes_dict_value))
-                        odds_onlys.append(odds_only)
-                        if odds_only not in odds_only_list:
-                            data_list.append(concedes_dict_data)
+                        data_list.append(concedes_dict_data)
                 else:
                     sole_str = 'CO' + str(key) + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     odds_str = 'CO' + str(key) + str(match_id) + 'hg3535' + str(
                         concedes_dict_rule[key]) + str(value)
-                    odds_only = Helper.genearte_MD5(odds_str)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
                     condition = fuhao(str(concedes_dict_rule[key]))
                     concedes_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                          "condition", "odds_only", "sole", "source", "type", "team"]
                     concedes_dict_value = [match_id, league_id, key, '0', 0, 'CO', value, condition,
                                            odds_only, sole, 'hg3535', '0', '']
                     concedes_dict_data = dict(zip(concedes_dict_key, concedes_dict_value))
-                    odds_onlys.append(odds_only)
-                    if odds_only not in odds_only_list:
-                        data_list.append(concedes_dict_data)
+                    data_list.append(concedes_dict_data)
         # 总得分单双
         if odd_evens_dict:
             for key, value in odd_evens_dict.items():
                 sole_str = 'TS' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'TS' + str(key) + str(match_id) + 'hg3535' + str(
                     odd_evens_dict_rule[key]) + str(value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(str(odd_evens_dict_rule[key]))
                 odd_evens_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                       "condition", "odds_only", "sole", "source", "type", "team"]
                 odd_evens_dict_value = [match_id, league_id, key, '0', 0, 'TS', value, condition,
                                         odds_only, sole, 'hg3535', '0', '']
                 odd_evens_dict_data = dict(zip(odd_evens_dict_key, odd_evens_dict_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(odd_evens_dict_data)
+                data_list.append(odd_evens_dict_data)
         # 总比分大小
         if total_sizes_dict:
             for key, value in total_sizes_dict.items():
                 if value:
                     for index, total_sizes_value in enumerate(value):
                         sole_str = 'TN' + str(key) + str(match_id) + 'hg3535'
-                        sole = Helper.genearte_MD5(sole_str)
+                        sole = Helper.genearte_MD5(sole_str, pt)
                         odds_str = 'TN' + str(key) + str(match_id) + 'hg3535' + str(
                             total_sizes_dict_rule[key][index]) + str(total_sizes_value)
-                        odds_only = Helper.genearte_MD5(odds_str)
+                        odds_only = Helper.genearte_MD5(odds_str, pt)
                         condition = fuhao(str(total_sizes_dict_rule[key][index]))
                         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, 'TN', total_sizes_value, condition,
                                              odds_only, sole, 'hg3535', '0', '']
                         total_sizes_data = dict(zip(total_sizes_key, total_sizes_value))
-                        odds_onlys.append(odds_only)
-                        if odds_only not in odds_only_list:
-                            data_list.append(total_sizes_data)
+                        data_list.append(total_sizes_data)
                 else:
                     sole_str = 'TN' + str(key) + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     odds_str = 'TN' + str(key) + str(match_id) + 'hg3535' + str(
                         total_sizes_dict_rule[key]) + str(value)
-                    odds_only = Helper.genearte_MD5(odds_str)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
                     condition = fuhao(str(total_sizes_dict_rule[key]))
                     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', 0, 'TN', value, condition,
                                          odds_only, sole, 'hg3535', '0', '']
                     total_sizes_data = dict(zip(total_sizes_key, total_sizes_value))
-                    odds_onlys.append(odds_only)
-                    if odds_only not in odds_only_list:
-                        data_list.append(total_sizes_data)
+                    data_list.append(total_sizes_data)
         # 球队得分大小
         if team_scores_dict:
             for key, value in team_scores_dict.items():
                 sole_str = 'TB' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'TB' + str(key) + str(match_id) + 'hg3535' + str(
                     team_scores_dict_rule[key]) + str(value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 condition = fuhao(str(team_scores_dict_rule[key]))
                 team_scores_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                    "condition", "odds_only", "sole", "source", "type", "team"]
                 team_scores_value = [match_id, league_id, key, '0', 0, 'TB', value, condition,
                                      odds_only, sole, 'hg3535', '0', '']
                 team_scores_data = dict(zip(team_scores_key, team_scores_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(team_scores_data)
-        # 球队得分最后一位数
+                data_list.append(team_scores_data)
 
+        # 球队得分最后一位数
         last_home_dict = {'0或5': 'lnh0', '1或6': 'lnh1', '2或7': 'lnh2', '3或8': 'lnh3', '4或9': 'lnh4'}
         last_home = last_numbers_dict['last_home']
         if last_home:
             for key, value in last_home.items():
-                for index, last_home_value in value.items():
-                    sole_str = 'LN' + last_home_dict[key] + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str)
-                    odds_str = 'LN' + last_home_dict[key] + str(match_id) + 'hg3535' + '0' + str(last_home_value)
-                    odds_only = Helper.genearte_MD5(odds_str)
-                    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, last_home_dict[key], '0', index, 'LN', last_home_value, '',odds_only, sole, 'hg3535', '0', '']
-                    last_home_data = dict(zip(last_home_key, last_home_value))
-                    odds_onlys.append(odds_only)
-                    if odds_only not in odds_only_list:
-                        data_list.append(last_home_data)
+            # for index, last_home_value in enumerate(value):
+                sole_str = 'LN' + last_home_dict[key] + str(match_id) + 'hg3535'
+                sole = Helper.genearte_MD5(sole_str)
+                odds_str = 'LN' + last_home_dict[key] + str(match_id) + 'hg3535' + '0' + str(last_home_value)
+                odds_only = Helper.genearte_MD5(odds_str)
+                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, last_home_dict[key], '0', index, 'LN', last_home_value, '',odds_only, sole, 'hg3535', '0', '']
+                last_home_data = dict(zip(last_home_key, last_home_value))
+                odds_onlys.append(odds_only)
+                if odds_only not in odds_only_list:
+                    data_list.append(last_home_data)
 
         last_guest = last_numbers_dict['last_guest']
         last_guest_dict = {'0或5': 'lng0', '1或6': 'lng1', '2或7': 'lng2', '3或8': 'lng3', '4或9': 'lng4'}
         if last_guest:
-            for key, value in last_numbers_dict.items():
-                for index, last_guest_value in value.items():
-                    sole_str = 'LN' + last_guest_dict[key] + str(match_id) + 'hg3535'
-                    sole = Helper.genearte_MD5(sole_str)
-                    odds_str = 'LN' + last_guest_dict[key] + str(match_id) + 'hg3535' + '0' + str(
-                        last_guest_value)
-                    odds_only = Helper.genearte_MD5(odds_str)
-                    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, key, '0', index, 'LN', last_guest_value, '',
-                                          odds_only, sole, 'hg3535', '0', '']
-                    last_guest_data = dict(zip(last_guest_key, last_guest_value))
-                    odds_onlys.append(odds_only)
-                    if odds_only not in odds_only_list:
-                        data_list.append(last_guest_data)
+            pass
+            # for key, value in last_numbers_dict.items():
+            #     for index, last_guest_value in enumerate(value):
+            #         sole_str = 'LN' + last_guest_dict[key] + str(match_id) + 'hg3535'
+            #         sole = Helper.genearte_MD5(sole_str)
+            #         odds_str = 'LN' + last_guest_dict[key] + str(match_id) + 'hg3535' + '0' + str(
+            #             last_guest_value)
+            #         odds_only = Helper.genearte_MD5(odds_str)
+            #         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, key, '0', index, 'LN', last_guest_value, '',
+            #                               odds_only, sole, 'hg3535', '0', '']
+            #         last_guest_data = dict(zip(last_guest_key, last_guest_value))
+            #         odds_onlys.append(odds_only)
+            #         if odds_only not in odds_only_list:
+            #             data_list.append(last_guest_data)
 
         # 独赢
         if capots_dict:
             for key, value in capots_dict.items():
                 sole_str = 'C' + str(key) + str(match_id) + 'hg3535'
-                sole = Helper.genearte_MD5(sole_str)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_str = 'C' + str(key) + str(match_id) + 'hg3535' + str(value)
-                odds_only = Helper.genearte_MD5(odds_str)
+                odds_only = Helper.genearte_MD5(odds_str, pt)
                 capots_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                               "condition", "odds_only", "sole", "source", "type", "team"]
                 capots_value = [match_id, league_id, key, '0', 0, 'C', value, '',
                                 odds_only, sole, 'hg3535', '0', '']
                 capots_data = dict(zip(capots_key, capots_value))
-                odds_onlys.append(odds_only)
-                if odds_only not in odds_only_list:
-                    data_list.append(capots_data)
+                data_list.append(capots_data)
         if pt == 3:
             ris_stringscene = 1
         else:
@@ -377,14 +293,14 @@ class Lanqiupipeline(object):
         odds_value = ["lq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid,
                       ris_stringscene, utime, pt]
         odds_dict = dict(zip(odds_key, odds_value))
-        # print(odds_dict)
-        # print(123)
         if data_list:
-            res = Helper.async_post(url + '/setOdds', odds_dict)
-            print(res)
-            if '成功' in res:
-                if result:
-                    self.db.hg3535_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)
+            response_data = Helper.async_post(settings.ODDS_URL, odds_dict)
+            if '成功' in response_data:
+                logger.info('篮球详细赔率提交成功, {}'.format(response_data))
+                logger.info(odds_dict)
+            else:
+                logger.warning('篮球详细赔率提交成功, {}'.format(response_data))
+                logger.warning(odds_dict)
+        else:
+            logger.info('详细赔率')
+        # reactor.callFromThread(out.callback, item)

+ 24 - 14
hg3535/pipeline/roll_lanqiu.py

@@ -1,6 +1,9 @@
 import pymongo
 import time
 import logging
+
+from twisted.internet import defer, reactor
+
 from .ball_func import fuhao
 from ..utils.helper import Helper
 
@@ -15,6 +18,12 @@ class Roll_Lanqiupipeline(object):
         self.db = self.mongo['kaiyou']
 
     def process_item(self, item, spider):
+        out = defer.Deferred()
+        reactor.callInThread(self._do_calculation, item, out)
+        yield out
+        defer.returnValue(item)
+
+    def _do_calculation(self, item, out):
         url = 'http://admin.5gogo.com'
         roll_lq = []
         # 使用twisted将mysql插入变成异步执行
@@ -155,8 +164,8 @@ class Roll_Lanqiupipeline(object):
                         hash_str = "CO" + str(key) + str(index) + str(concedes_dict_rule[key][index]) + str(
                             concede_value) + "hg3535" + str(match_id)
                         sole_str = "CO" + str(key) + str(index) + str(match_id) + "hg3535"
-                        odds_only = Helper.genearte_MD5(hash_str)
-                        sole = Helper.genearte_MD5(sole_str)
+                        odds_only = Helper.genearte_MD5(hash_str, pt)
+                        sole = Helper.genearte_MD5(sole_str, pt)
                         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"]
@@ -174,8 +183,8 @@ class Roll_Lanqiupipeline(object):
                         hash_str = "total_size" + str(key) + str(index) + str(condition) + str(
                             total_sizes_value) + "hg3535" + str(match_id)
                         sole_str = "total_size" + str(key) + str(index) + str(match_id) + "hg3535"
-                        odds_only = Helper.genearte_MD5(hash_str)
-                        sole = Helper.genearte_MD5(sole_str)
+                        odds_only = Helper.genearte_MD5(hash_str, pt)
+                        sole = Helper.genearte_MD5(sole_str, pt)
                         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"]
@@ -192,8 +201,8 @@ class Roll_Lanqiupipeline(object):
                     hash_str = "TS" + str(key) + '0' + str(condition) + str(
                         value) + "hg3535" + str(match_id)
                     sole_str = "TS" + str(key) + '0' + str(match_id) + "hg3535"
-                    odds_only = Helper.genearte_MD5(hash_str)
-                    sole = Helper.genearte_MD5(sole_str)
+                    odds_only = Helper.genearte_MD5(hash_str, pt)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     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"]
@@ -214,8 +223,8 @@ class Roll_Lanqiupipeline(object):
                 hash_str = "LN" + odds_code + '0' + str(condition) + str(
                     value) + "hg3535" + str(match_id)
                 sole_str = "LN" + str(key) + '0' + str(match_id) + "hg3535"
-                odds_only = Helper.genearte_MD5(hash_str)
-                sole = Helper.genearte_MD5(sole_str)
+                odds_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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"]
@@ -232,8 +241,8 @@ class Roll_Lanqiupipeline(object):
                 condition = lastnumber_dict[key]
                 hash_str = "LN" + odds_code + '0' + str(condition) + str(value) + "hg3535" + str(match_id)
                 sole_str = "LN" + str(key) + '0' + str(match_id) + "hg3535"
-                odds_only = Helper.genearte_MD5(hash_str)
-                sole = Helper.genearte_MD5(sole_str)
+                odds_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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"]
@@ -248,8 +257,8 @@ class Roll_Lanqiupipeline(object):
                 if value:
                     hash_str = "C" + str(key) + '0' + '0' + str(value) + "hg3535" + str(match_id)
                     sole_str = "C" + str(key) + '0' + str(match_id) + "hg3535"
-                    odds_only = Helper.genearte_MD5(hash_str)
-                    sole = Helper.genearte_MD5(sole_str)
+                    odds_only = Helper.genearte_MD5(hash_str, pt)
+                    sole = Helper.genearte_MD5(sole_str, pt)
                     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"]
@@ -266,8 +275,8 @@ class Roll_Lanqiupipeline(object):
                         hash_str = "TB" + str(key) + str(index) + str(team_scores_dict_rule[key][index]) + str(
                             value) + "hg3535" + str(match_id)
                         sole_str = "TB" + str(key) + str(index) + str(match_id) + "hg3535"
-                        odds_only = Helper.genearte_MD5(hash_str)
-                        sole = Helper.genearte_MD5(sole_str)
+                        odds_only = Helper.genearte_MD5(hash_str, pt)
+                        sole = Helper.genearte_MD5(sole_str, pt)
                         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"]
@@ -318,3 +327,4 @@ class Roll_Lanqiupipeline(object):
             except Exception as e:
                 logger.warning('滚球数据接口异常,提交失败')
                 logger.warning(e)
+        reactor.callFromThread(out.callback, item)

+ 1 - 1
hg3535/pipeline/roll_wangqiu.py

@@ -165,7 +165,7 @@ class Roll_Wangqiupipeline(object):
                     sole_str = 'C' + str(key) + '0' + str(match_id) + 'hg3535'
                     sole = Helper.genearte_MD5(sole_str)
                     odds_str = 'C' + str(key) + '0' + '0' + str(value) + 'hg3535' + str(match_id)
-                    odds_only = Helper.genearte_MD5(odds_str)
+                    odds_only = Helper.genearte_MD5(odds_str, pt)
                     kemps_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                  "condition", "odds_only", "sole", "source", "type", "team"]
                     kemps_value = [match_id, league_id, key, "0", 0, 'C', value, '',

+ 146 - 218
hg3535/pipeline/roll_zuqiu.py

@@ -1,45 +1,52 @@
 # import datetime
+import datetime
+
 import pymongo
 import time
 import logging
+
+from twisted.internet import defer, reactor
+
 from .ball_func import fuhao
 from ..utils.helper import Helper
 from .ball_func import get_pcode
+import settings
 
 
 # 滚球足球 插入
 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']
+        self.mongo = pymongo.MongoClient(host=settings.M_HOST, username=settings.M_USER, password=settings.M_PASSWORD, port=settings.M_POST)
+        self.db = self.mongo[settings.M_DB]
 
+    @defer.inlineCallbacks
     def process_item(self, item, spider):
+        out = defer.Deferred()
+        reactor.callInThread(self._do_calculation, item, out)
+        yield out
+        defer.returnValue(item)
+
+    def _do_calculation(self, item, out):
         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])
+        # 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))
+        match_date = datetime.datetime.now().strftime("%Y-%m-%d")
         # 比赛id
         match_id = item['game_id']
         # 联赛id
@@ -56,91 +63,48 @@ class Roll_Zuqiupipeline(object):
         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)
+        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"}
+        last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
         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)
+        uuid = Helper.genearte_uuid(league_name + 'hg3535')
+        if self.db.zq_league35.find({'league_id': league_id}).count() < 1:
+            league_dict = {"game_code": "zq", "title": "league", "source": "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(settings.LEAGUE_URL, league_dict)
             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("赛事已存在,赛事状态时间为改变,不做修改")
+                logger.warning('足球滚球联赛提交失败, {}'.format(response_data))
+                logger.warning(league_dict)
         else:
-            is_rollball = 1
-            is_today = 0
-            is_morningplate = 0
-            is_stringscene = 0
-            # 赛事接口写入
+            logger.info('足球滚球联赛已存在, 不存在')
+        if self.db.zq_competition35.find({"match_id": match_id, 'is_rollball': 1}).count() < 1:
+            match_list = []
             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",
+            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_value = [team_home, team_guest, league_id, 1, match_id, match_date, '00:00', number,
+                           "hg3535", 1, 0, 0, utime, uuid, 0, 0]
             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)
+            response_data = Helper.async_post(settings.MATCH_URL, match_dict)
             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')
+                self.db.zq_competition35.insert(match_data)
+        else:
+            logger.info('足球滚球赛事已存在, 不提交')
         p_code = "GS"
         # 构建唯一索引
         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 = []
 
@@ -158,24 +122,22 @@ class Roll_Zuqiupipeline(object):
             half_size_guest_value = [match_id, league_id, "gss_h", "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)
+            data_list.append(half_size_guest_data)
+
         # half_size_home
         for index, value in enumerate(half_size_home):
             hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
-            odds_onlys.append(odds_only)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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, "gsb_h", "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)
+            data_list.append(half_size_home_data)
 
         # 全场场大小
         size_guest = item["size_guest"]
@@ -187,35 +149,31 @@ class Roll_Zuqiupipeline(object):
             hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
                 match_id)
             sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
-            odds_onlys.append(odds_only)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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, "gsb", "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)
+            data_list.append(size_home_data)
+
         # size_guest
         for index, value in enumerate(size_guest):
             hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
                 match_id)
             sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
-            odds_onlys.append(odds_only)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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, "gss", "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)
+            data_list.append(size_home_data)
 
-        # p_code, p_id = get_pcode(corner_ball, 'concede')
         p_code = 'CO'
         half_concede_home_rule = item["half_concede_home_rule"]
         half_concede_home = item["half_concede_home"]
@@ -226,8 +184,8 @@ class Roll_Zuqiupipeline(object):
             hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -235,24 +193,22 @@ class Roll_Zuqiupipeline(object):
             half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
                                         odds_only, sole, "hg3535", "0", ""]
             half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
-            if odds_only not in uuid_list:
-                data_list.append(half_concede_guest_data)
+            data_list.append(half_concede_guest_data)
+
         # half_concede_home
         for index, value in enumerate(half_concede_home):
             hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
-            odds_onlys.append(odds_only)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                                      "odds_only", "sole", "source", "type", "team"]
             condition = fuhao(half_concede_home_rule[index])
             half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
                                        odds_only, sole, "hg3535", "0", ""]
             half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
-            if odds_only not in uuid_list:
-                data_list.append(half_concede_home_data)
+            data_list.append(half_concede_home_data)
 
         concede_guest = item["concede_guest"]
         concede_guest_rule = item["concede_guest_rule"]
@@ -263,36 +219,32 @@ class Roll_Zuqiupipeline(object):
             hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
-            odds_onlys.append(odds_only)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                                  "odds_only", "sole", "source", "type", "team"]
             condition = fuhao(concede_guest[index])
             concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
                                    odds_only, sole, "hg3535", "0", ""]
             concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
-            if odds_only not in uuid_list:
-                data_list.append(concede_guest_data)
+            data_list.append(concede_guest_data)
+
         # concede_home
         for index, value in enumerate(concede_home):
             hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
-            odds_onlys.append(odds_only)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                                 "odds_only", "sole", "source", "type", "team"]
             condition = fuhao(concede_home_rule[index])
             concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
                                   sole, "hg3535", "0", ""]
             concede_guest_data = dict(zip(concede_home_key, concede_home_value))
-            if odds_only not in uuid_list:
-                data_list.append(concede_guest_data)
+            data_list.append(concede_guest_data)
 
         # 独赢----------------------------------------------------------------------------------------------------------
-        # p_code, p_id = get_pcode(corner_ball, 'capot')
         p_code = 'C'
         half_capot_home = item["half_capot_home"]
         half_capot_guest = item["half_capot_guest"]
@@ -304,87 +256,77 @@ class Roll_Zuqiupipeline(object):
         # half_capot_home
         hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
         sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "ch_h", "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)
+        data_list.append(half_capot_homet_data)
 
         # half_capot_guest
         hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
         sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
-        odds_onlys.append(odds_only)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "cg_h", "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)
+        data_list.append(half_capot_guest_data)
 
         # half_capot_dogfall
         hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
         sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "cd_h", "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)
+        data_list.append(half_capot_dogfall_data)
         # capot_dogfall
         hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
         sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
-        odds_onlys.append(odds_only)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "cd", "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)
+        data_list.append(capot_dogfall_data)
 
         # capot_home
         hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
         sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
-        odds_onlys.append(odds_only)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "ch", "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)
+        data_list.append(capot_homet_data)
+
         # capot_guest
         hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
         sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
-        odds_onlys.append(odds_only)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
                            "odds_only", "sole", "source", "type", "team"]
         capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_home, '2',
                              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)
+        data_list.append(capot_guest_data)
 
         # 入球数单双-----------------------------------------------------------------------------------------------------
-        # p_code, p_id = get_pcode(corner_ball, 'two_sides')
         p_code = 'TS'
         odd_even_odd = item["odd_even_odd"]
         odd_even_even = item["odd_even_even"]
@@ -394,75 +336,68 @@ class Roll_Zuqiupipeline(object):
         # odd_even_odd
         hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
         sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "tss", "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)
+        data_list.append(single_data)
+
         # odd_even_even
         hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
         sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
-        odds_onlys.append(odds_only)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "tss", "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)
+        data_list.append(double_data)
+
         # half_odd_even_even
         hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
         sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
-        odds_onlys.append(odds_only)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "tsd_h", "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)
+        data_list.append(half_double_data)
+
         # half_odd_even_odd
         hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
         sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
-        odds_onlys.append(odds_only)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "tss_h", "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)
+        data_list.append(half_single_data)
+
         # 总入球数 ------------------------------------------------------------------------------------------------------
-        # p_code, p_id = get_pcode(corner_ball, 'total_goal')
         total_goals = item['total_goal']
         total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6','tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
                       "tg2_h": '2', "tg3_h": '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)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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)
+            data_list.append(total_goals_data)
 
         # 全场半场 ------------------------------------------------------------------------------------------------------
         half_fulls = item['half_full']
@@ -474,16 +409,14 @@ class Roll_Zuqiupipeline(object):
             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)
+                odds_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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)
+                data_list.append(half_fulls_data)
 
         # 波胆------------------------------------------------------------------------------------------------------------------
         bodan_datas = item['bodan_data']
@@ -500,28 +433,25 @@ class Roll_Zuqiupipeline(object):
             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)
+                odds_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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)
+                data_list.append(bodan_dict_data)
 
         # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
         first_last_balls = item['first_last_ball']
-        # p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
         p_code = 'FLB'
         first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
         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_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 odds_onlys.append(odds_only)
                 first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
                                         "condition",
@@ -530,10 +460,8 @@ class Roll_Zuqiupipeline(object):
                                           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)
+                data_list.append(first_last_balls_data)
 
-        # p_code, p_id = get_pcode(corner_ball, 'tema_ball')
         p_code = 'TB'
         # 球队得分全场,上半场
         full_dicts = item['full_data']
@@ -544,47 +472,43 @@ class Roll_Zuqiupipeline(object):
             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_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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)
+                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_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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)
+                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)
+            response_data = Helper.async_post(settings.ODDS_URL, odds_dict)
             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)
+                logger.info('足球滚球详细赔率提交成功, {}'.format(response_data))
+            else:
+                logger.warning('足球滚球详细赔率提交失败, {}'.format(response_data))
+                logger.warning(odds_dict)
+        else:
+            logger.info('足球滚球详细赔率列表为空')
         data_list = []
         zq_rball = {"home_team": team_home, "guest_team": team_guest,
                     "lg_id": league_id, "home_rate": 0,
@@ -603,12 +527,16 @@ class Roll_Zuqiupipeline(object):
         }
         if data_list:
             try:
-                response_data = Helper.async_post(url + '/setMatchResult', r_data_dict)
-                print(r_data_dict)
-                print("滚球赛事结果post提交", response_data)
+                response_data = Helper.async_post(settings.MATCH_RESULT, r_data_dict)
+                if "成功" in response_data:
+                    logger.info('足球滚球结果记录提交成功, {}'.format(response_data))
+                    logger.info(r_data_dict)
+                else:
+                    logger.warning('足球滚球结果记录提交失败, {}'.format(response_data))
+                    logger.warning(r_data_dict)
             except Exception as e:
-                logger.warning('滚球数据接口异常,提交失败')
-                logger.warning(e)
+                logger.warning('滚球数据接口异常,提交失败, {}'.format(e))
+        reactor.callFromThread(out.callback, item)
 
 
 

+ 134 - 891
hg3535/pipeline/zuqiu.py

@@ -1,65 +1,33 @@
-import asyncio
 import datetime
-import json
-import aiohttp
 import time
 import logging
 
-from motor.motor_asyncio import AsyncIOMotorClient
+import pymongo
+from twisted.internet import defer, reactor
 from .ball_func import fuhao
 from ..utils.helper import Helper
 from .ball_func import new_time
-# from concurrent.futures import ThreadPoolExecutor
-# from requests_futures.sessions import FuturesSession
 
+from ..settings import M_HOST, M_USER, M_PASSWORD, M_POST, M_DB, LEAGUE_URL, ODDS_URL, MATCH_URL, MATCH_RESULT
 
-class Zuqiupipeline(object):
 
+class Zuqiupipeline(object):
     def open_spider(self, spider):
-        self.connection = AsyncIOMotorClient("mongodb://{}:{}@{}:{}/database?authSource={}".format('kaiyou', 'kaiyou', '192.168.2.200', 27017, 'kaiyou'))
-        self.session = aiohttp.ClientSession()
-        self.url = 'http://admin.5gogo.com'
+        # self.connection = AsyncIOMotorClient("mongodb://{}:{}@{}:{}/database?authSource={}".format('kaiyou', 'kaiyou', '192.168.2.200', 27017, 'kaiyou'))
+        # session = aiohttp.ClientSession()
+        self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST)
+        self.db = self.mongo[M_DB]
 
+    @defer.inlineCallbacks
     def process_item(self, item, spider):
-        loop = asyncio.get_event_loop()
-        tasks = [
-            asyncio.ensure_future(self._league(item)),
-            asyncio.ensure_future(self._match(item)),
-            asyncio.ensure_future(self._odds(item))
-        ]
-        loop.run_until_complete(asyncio.wait(tasks))
+        out = defer.Deferred()
+        reactor.callInThread(self._do_calculation, item, out)
+        yield out
+        defer.returnValue(item)
 
-    async def _league(self, item):
-        logger = logging.getLogger(__name__)
-        # 联赛id
-        league_id = item['league_id']
-        # 联赛name
-        league_name = item['league_name']
-        # 联赛接口写入
-        last_time = '2019-12-31 23:59:59'
-        uuid = Helper.genearte_MD5(league_name + 'hg3535')
-        _zq_league = await self.connection.get_database('kaiyou').zq_league35.find_one({'uuid': uuid})
-        if not _zq_league:
-            league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
-            league_list = []
-            league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
-            league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
-            league_data = dict(zip(league_key, league_value))
-            league_list.append(league_data)
-            league_dict['data'] = league_list
-            response_data = await self.session.post(self.url + '/setLeague', data={"data": json.dumps(league_dict),
-                                                                                   "token": 'JlUo1415650051585d481566c10c9'})
-            if response_data.status == 200:
-                await self.connection.get_database('kaiyou').zq_league35.insert_one(league_data)
-                logger.info(league_dict)
-            else:
-                logger.warning(response_data.status)
-                logger.warning(league_dict)
-        else:
-            logger.info('足球联赛已存在')
-
-    async def _match(self, item):
+    def _do_calculation(self, item, out):
         logger = logging.getLogger(__name__)
+        # 比赛日期
         try:
             data_game = item['data_game'].split("/")
             month = str(data_game[1].strip())
@@ -72,11 +40,13 @@ class Zuqiupipeline(object):
                           '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"
+        # 现在时间,时间戳
+        utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
         # 比赛id
         match_id = item['game_id']
         # 联赛id
@@ -90,10 +60,22 @@ class Zuqiupipeline(object):
         # number
         tag_number = item['number']
         pt = item['pt']
-        # corner_ball = item['corner_ball']
+        corner_ball = item['corner_ball']
         match_date, match_time, time3 = new_time(us_time)
         # 联赛接口写入
-        uuid = Helper.genearte_MD5(league_name + 'hg3535')
+        last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
+        league_list = []
+        uuid = Helper.genearte_uuid(league_name + 'hg3535')
+        if self.db.zq_league35.find({'lg_id': league_id}).count() < 1:
+            league_dict = {"game_code": "zq", "title": "league", "source": "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(LEAGUE_URL, league_dict)
+            if "成功" in response_data:
+                self.db.zq_league35.insert(league_list)
         pt_dict = {'1': 'is_today', '2': 'is_morningplate', '3': 'is_stringscene', '4': 'is_rollball'}
         pt_status = pt_dict[pt]
         if pt == '3':
@@ -111,10 +93,9 @@ class Zuqiupipeline(object):
             is_rollball = 0
             is_morningplate = 0
             is_stringscene = 0
-        _zq_match = await self.connection.get_database('kaiyou').zq_competition35.find_one({'match_id': match_id, pt_status: 1})
 
-        if not _zq_match:
-            match_list = []
+        match_list = []
+        if self.db.zq_competition35.find({'match_id': match_id, pt_status: 1}).count() < 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",
@@ -124,81 +105,21 @@ class Zuqiupipeline(object):
             match_data = dict(zip(match_kay, match_value))
             match_list.append(match_data)
             match_dict['data'] = match_list
-            response_data = await self.session.post(self.url + '/setMatch',
-                                                    data={"data": json.dumps(match_data), "token": 'JlUo1415650051585d481566c10c9'})
-            if response_data.status == 200:
-                await self.connection.get_database('kaiyou').zq_competition35.insert_one(match_data)
+            response_data = Helper.async_post(MATCH_URL, match_dict)
+            if "成功" in response_data:
+                self.db.zq_competition35.insert(match_data)
             else:
-                logger.warning(response_data.status)
+                logger.warning('足球赛事表提交失败, {}'.format(response_data))
                 logger.warning(match_dict)
         else:
-            logger.info('足球赛事已存在')
-
-    async def _odds(self, item):
-        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])
+            logger.info('足球赛事已存在,不提交')
 
-        # 比赛时间
-        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'
-        uuid = Helper.genearte_MD5(league_name + 'hg3535')
-        # 赔率
-        _zq_odds = await self.connection.get_database('kaiyou').zq_zodds35.find_one({'match_id': match_id})
-        if _zq_odds:
-            _uid_list = _zq_odds['uid']
-            pass
-        else:
-            _uid_list = []
-        # 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')
-        # 构建唯一索引
         p_code = "GS"
         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']
+        # zuqiu = item['zuqiu']
         data_list = []
         odds_onlys = []
         # half_size_guest
@@ -206,8 +127,8 @@ class Zuqiupipeline(object):
             hash_str = p_code + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "gss_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -215,16 +136,14 @@ class Zuqiupipeline(object):
             half_size_guest_value = [match_id, league_id, "gss_h", "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 _uid_list:
-                data_list.append(half_size_guest_data)
-                _uid_list.append(odds_only)
+            data_list.append(half_size_guest_data)
         # half_size_home
         for index, value in enumerate(half_size_home):
             hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -232,10 +151,7 @@ class Zuqiupipeline(object):
             half_size_home_value = [match_id, league_id, "gsb_h", "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 _uid_list:
-                _uid_list.append(odds_only)
-                data_list.append(half_size_home_data)
+            data_list.append(half_size_home_data)
 
         # 全场场大小
         size_guest = item["size_guest"]
@@ -247,8 +163,8 @@ class Zuqiupipeline(object):
             hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
                 match_id)
             sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -256,16 +172,14 @@ class Zuqiupipeline(object):
             size_home_value = [match_id, league_id, "gsb", "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 _uid_list:
-                data_list.append(size_home_data)
-                _uid_list.append(odds_only)
+            data_list.append(size_home_data)
         # size_guest
         for index, value in enumerate(size_guest):
             hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
                 match_id)
             sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -273,11 +187,8 @@ class Zuqiupipeline(object):
             size_guest_value = [match_id, league_id, "gss", "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 _uid_list:
-                data_list.append(size_home_data)
-                _uid_list.append(odds_only)
+            data_list.append(size_home_data)
 
-        # p_code, p_id = get_pcode(corner_ball, 'concede')
         p_code = 'CO'
         half_concede_home_rule = item["half_concede_home_rule"]
         half_concede_home = item["half_concede_home"]
@@ -288,8 +199,8 @@ class Zuqiupipeline(object):
             hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -297,17 +208,15 @@ class Zuqiupipeline(object):
             half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
                                         odds_only, sole, "hg3535", "0", ""]
             half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
-            # if uid_num < 1:
-            if odds_only not in _uid_list:
-                data_list.append(half_concede_guest_data)
-                _uid_list.append(odds_only)
+            data_list.append(half_concede_guest_data)
+
         # half_concede_home
         for index, value in enumerate(half_concede_home):
             hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -315,9 +224,7 @@ class Zuqiupipeline(object):
             half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
                                        odds_only, sole, "hg3535", "0", ""]
             half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
-            if odds_only not in _uid_list:
-                data_list.append(half_concede_home_data)
-                _uid_list.append(odds_only)
+            data_list.append(half_concede_home_data)
 
         concede_guest = item["concede_guest"]
         concede_guest_rule = item["concede_guest_rule"]
@@ -328,8 +235,8 @@ class Zuqiupipeline(object):
             hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -337,16 +244,14 @@ class Zuqiupipeline(object):
             concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
                                    odds_only, sole, "hg3535", "0", ""]
             concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
-            if odds_only not in _uid_list:
-                data_list.append(concede_guest_data)
-                _uid_list.append(odds_only)
+            data_list.append(concede_guest_data)
         # concede_home
         for index, value in enumerate(concede_home):
             hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
                 value) + "hg3535" + str(match_id)
             sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
-            odds_only = Helper.genearte_MD5(hash_str)
-            sole = Helper.genearte_MD5(sole_str)
+            odds_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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"]
@@ -354,12 +259,9 @@ class Zuqiupipeline(object):
             concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
                                   sole, "hg3535", "0", ""]
             concede_guest_data = dict(zip(concede_home_key, concede_home_value))
-            if odds_only not in _uid_list:
-                data_list.append(concede_guest_data)
-                _uid_list.append(odds_only)
+            data_list.append(concede_guest_data)
 
         # 独赢----------------------------------------------------------------------------------------------------------
-        # p_code, p_id = get_pcode(corner_ball, 'capot')
         p_code = 'C'
         half_capot_home = item["half_capot_home"]
         half_capot_guest = item["half_capot_guest"]
@@ -371,92 +273,80 @@ class Zuqiupipeline(object):
         # half_capot_home
         hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
         sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "ch_h", "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 _uid_list:
-            data_list.append(half_capot_homet_data)
-            _uid_list.append(odds_only)
+        data_list.append(half_capot_homet_data)
 
         # half_capot_guest
         hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
         sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "cg_h", "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 _uid_list:
-            data_list.append(half_capot_guest_data)
-            _uid_list.append(odds_only)
+        data_list.append(half_capot_guest_data)
 
         # half_capot_dogfall
         hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
         sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "cd_h", "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 _uid_list:
-            data_list.append(half_capot_dogfall_data)
-            _uid_list.append(odds_only)
+        data_list.append(half_capot_dogfall_data)
 
         # capot_dogfall
         hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
         sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "cd", "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 _uid_list:
-            data_list.append(capot_dogfall_data)
-            _uid_list.append(odds_only)
+        data_list.append(capot_dogfall_data)
 
         # capot_home
         hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
         sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "ch", "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 _uid_list:
-            data_list.append(capot_homet_data)
-            _uid_list.append(odds_only)
+        data_list.append(capot_homet_data)
 
         # capot_guest
         hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
         sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "cg", "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 _uid_list:
-            data_list.append(capot_guest_data)
-            _uid_list.append(odds_only)
+        data_list.append(capot_guest_data)
 
         # 入球数单双-----------------------------------------------------------------------------------------------------
         # p_code, p_id = get_pcode(corner_ball, 'two_sides')
@@ -469,89 +359,77 @@ class Zuqiupipeline(object):
         # odd_even_odd
         hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
         sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "tss", "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 _uid_list:
-            data_list.append(single_data)
-            _uid_list.append(odds_only)
+        data_list.append(single_data)
 
         # odd_even_even
         hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
         sole_str = p_code + "tsd" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "tsd", "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 _uid_list:
-            data_list.append(double_data)
-            _uid_list.append(odds_only)
+        data_list.append(double_data)
 
         # half_odd_even_even
         hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
         sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "tsd_h", "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 _uid_list:
-            data_list.append(half_double_data)
-            _uid_list.append(odds_only)
+        data_list.append(half_double_data)
 
         # half_odd_even_odd
         hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
         sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
-        odds_only = Helper.genearte_MD5(hash_str)
-        sole = Helper.genearte_MD5(sole_str)
+        odds_only = Helper.genearte_MD5(hash_str, pt)
+        sole = Helper.genearte_MD5(sole_str, pt)
         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, "tss_h", "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 _uid_list:
-            data_list.append(half_single_data)
-            _uid_list.append(odds_only)
+        data_list.append(half_single_data)
 
         # 总入球数 ------------------------------------------------------------------------------------------------------
-        # p_code, p_id = get_pcode(corner_ball, 'total_goal')
         p_code = 'TG'
         total_goals = item['total_goal']
-        total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6', 'tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
+        total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6','tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
                       "tg2_h": '2', "tg3_h": '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_only = Helper.genearte_MD5(hash_str, pt)
+            sole = Helper.genearte_MD5(sole_str, pt)
             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 _uid_list:
-                data_list.append(total_goals_data)
-                _uid_list.append(odds_only)
+            data_list.append(total_goals_data)
 
         # 全场半场 ------------------------------------------------------------------------------------------------------
         half_fulls = item['half_full']
-        # p_code, p_id = get_pcode(corner_ball, 'half_full')
         p_code = 'HF'
         full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
                      "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
@@ -559,21 +437,18 @@ class Zuqiupipeline(object):
             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_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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"]
+                                   "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", ""]
+                                     sole, "hg3535", "0", ""]
                 half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
-                if odds_only not in _uid_list:
-                    data_list.append(half_fulls_data)
-                    _uid_list.append(odds_only)
+                data_list.append(half_fulls_data)
 
-        # 波胆------------------------------------------------------------------------------------------------------------------
+        # 波胆-----------------------------------------------------------------------------------------------------------
         bodan_datas = item['bodan_data']
-        # p_code, p_id = get_pcode(corner_ball, 'bodan')
         p_code = 'B'
         bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
                       "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
@@ -587,17 +462,15 @@ class Zuqiupipeline(object):
             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_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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 _uid_list:
-                    data_list.append(bodan_dict_data)
-                    _uid_list.append(odds_only)
+                data_list.append(bodan_dict_data)
 
         # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
         first_last_balls = item['first_last_ball']
@@ -608,21 +481,16 @@ class Zuqiupipeline(object):
             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_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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_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 _uid_list:
-                    data_list.append(first_last_balls_data)
-                    _uid_list.append(odds_only)
+                data_list.append(first_last_balls_data)
 
-        # p_code, p_id = get_pcode(corner_ball, 'tema_ball')
         # 球队得分大小
         p_code = 'TB'
         # 全场
@@ -635,667 +503,42 @@ class Zuqiupipeline(object):
             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_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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"]
+                                        "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", ""]
+                                          odds_only,sole, "hg3535", "0", ""]
                 full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
-                if odds_only not in _uid_list:
-                    data_list.append(full_dict_rules_data)
-                    _uid_list.append(odds_only)
+                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_only = Helper.genearte_MD5(hash_str, pt)
+                sole = Helper.genearte_MD5(sole_str, pt)
                 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"]
+                                "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", ""]
+                                         odds_only, sole, "hg3535", "0", ""]
                 half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
-                if odds_only not in _uid_list:
-                    data_list.append(half_dicts_data)
-                    _uid_list.append(odds_only)
+                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_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(self.url + '/setOdds', odds_dict)
-            response_data = await self.session.post(self.url + '/setOdds',
-                                                    data={"data": json.dumps(odds_dict), "token": 'JlUo1415650051585d481566c10c9'})
-            if response_data.status == 200:
-                    # self.db.hg3535_zq_odds.update({'match_id': match_id, 'pt': pt}, {
-                    #     '$set': {"data": data_list, "odds_only": odds_onlys, "utime": utime}}, upsert=True)
-                if _zq_odds:
-                    pass
-                    await self.connection.get_database('kaiyou').zq_odds35.update_one({'match_id': match_id}, {'$set': {'uid': odds_onlys}})
-                else:
-                    await self.connection.get_database('kaiyou').zq_odds35.insert_one(
-                        {'match_id': match_id, 'uid': odds_onlys})
+            response_data = Helper.async_post(ODDS_URL, odds_dict)
+            if "成功" in response_data:
+                logger.info('足球详细赔率提交成功, {}'.format(response_data))
+                logger.info(odds_dict)
             else:
-                logger.info('赔率提交失败')
-
-    # async def match_all(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')
-    #     # 构建唯一索引
-    #     p_code = "GS"
-    #     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 + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
-    #             value) + "hg3535" + str(match_id)
-    #         sole_str = p_code + "gss_h" + 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, "gss_h", "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 + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
-    #             value) + "hg3535" + str(match_id)
-    #         sole_str = p_code + "gsb_h" + 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, "gsb_h", "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 + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
-    #             match_id)
-    #         sole_str = p_code + "gsb" + 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, "gsb", "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 + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
-    #             match_id)
-    #         sole_str = p_code + "gss" + 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, "gss", "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')
-    #     p_code = 'CO'
-    #     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 + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
-    #             value) + "hg3535" + str(match_id)
-    #         sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
-    #         odds_only = Helper.genearte_MD5(hash_str)
-    #         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, "cog_h", "0", index, p_code, value, condition,
-    #                                     odds_only, sole, "hg3535", "0", ""]
-    #         half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
-    #         # 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 + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
-    #             value) + "hg3535" + str(match_id)
-    #         sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
-    #         odds_only = Helper.genearte_MD5(hash_str)
-    #         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, "coh_h", "0", index, p_code, value, condition,
-    #                                    odds_only, sole, "hg3535", "0", ""]
-    #         half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
-    #         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 + "cog" + str(index) + str(concede_guest_rule[index]) + str(
-    #             value) + "hg3535" + str(match_id)
-    #         sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
-    #         odds_only = Helper.genearte_MD5(hash_str)
-    #         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, "cog", "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 + "coh" + str(index) + str(concede_home_rule[index]) + str(
-    #             value) + "hg3535" + str(match_id)
-    #         sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
-    #         odds_only = Helper.genearte_MD5(hash_str)
-    #         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, "coh", "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')
-    #     p_code = 'C'
-    #     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 + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "ch_h" + '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, "ch_h", "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 + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "cg_h" + '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, "cg_h", "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 + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "cd_h" + '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, "cd_h", "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 + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "cd" + '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, "cd", "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 + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "ch" + '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, "ch", "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 + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "cg" + '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, "cg", "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')
-    #     p_code = 'TS'
-    #     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 + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "tss" + '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, "tss", "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 + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "tsd" + '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, "tsd", "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 + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "tsd_h" + '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, "tsd_h", "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 + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
-    #     sole_str = p_code + "tss_h" + '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, "tss_h", "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')
-    #     p_code = 'TG'
-    #     total_goals = item['total_goal']
-    #     total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6','tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
-    #                   "tg2_h": '2', "tg3_h": '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')
-    #     p_code = 'HF'
-    #     full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
-    #                  "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
-    #     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')
-    #     p_code = 'B'
-    #     bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
-    #                   "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
-    #                   "b12": "1-2", "b03": "0-3", "b13": "1-3", "b23": "2-3", "b04": "0-4", "b14": "1-4",
-    #                   "b24": "2-4", "b34": "3-4", "b00": "0-0", "b11": "1-1", "b22": "2-2", "b33": "3-3",
-    #                   "b44": "4-4", "bo": "其他", "b10_h": "1-0", "b20_h": "2-0", "b21_h": "2-1", "b30_h": "3-0",
-    #                   "b31_h": "3-1", "b32_h": "3-2", "b01_h": "0-1", "b02_h": "0-2", "b12_h": "1-2", "b03_h": "0-3",
-    #                   "b13_h": "1-3", "b23_h": "2-3", "b00_h": "0-0", "b11_h": "1-1", "b22_h": "2-2", "b33_h": "3-3",
-    #                   "bo_h": "其他"}
-    #     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')
-    #     p_code = 'FLB'
-    #     first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
-    #     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')
-    #     # 球队得分大小
-    #     p_code = 'TB'
-    #     # 全场
-    #     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)
+                logger.warning('足球相信赔率提交失败, {}'.format(response_data))
+                logger.warning(odds_dict)
+        reactor.callFromThread(out.callback, item)

+ 21 - 40
hg3535/settings.py

@@ -23,15 +23,15 @@ USER_AGENT = {
 ROBOTSTXT_OBEY = False
 
 # Configure maximum concurrent requests performed by Scrapy (default: 16)
-CONCURRENT_REQUESTS = 32
+CONCURRENT_REQUESTS = 8
 
 # Configure a delay for requests for the same website (default: 0)
 # See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay
 # See also autothrottle settings and docs
 # DOWNLOAD_DELAY = 3
-DOWNLOAD_DELAY = 0.15
+DOWNLOAD_DELAY = 0
 # The download delay setting will honor only one of:
-CONCURRENT_REQUESTS_PER_DOMAIN = 32
+CONCURRENT_REQUESTS_PER_DOMAIN = 8
 CONCURRENT_REQUESTS_PER_IP = 0
 
 # Disable cookies (enabled by default)
@@ -119,9 +119,9 @@ REACTOR_THREADPOOL_MAXSIZE = 40
 # LOG_LEVEL = 'INFO'
 COOKIES_ENABLED = False
 RETRY_ENABLED = False
-DOWNLOAD_TIMEOUT = 1
+DOWNLOAD_TIMEOUT = 10
 REDIRECT_ENABLED = False
-
+CONCURRENT_ITEMS = 1000
 # SCHEDULER_PERSIST = False  # 是否在关闭时候保留原来的调度器和去重记录,True=保留,False=清空
 # SCHEDULER_FLUSH_ON_START = False
 # TELNETCONSOLE_PORT = None
@@ -137,36 +137,17 @@ REDIRECT_ENABLED = False
 # LOG_FILE = './log/'
 
 
-# POST_HOST = 'localhost'
-# POST_DATABASE = 'postgres'
-# POST_USER = 'postgres'
-# POST_PORT = '5433'
-# POST_PASSWORD = '123456'
+M_HOST = '192.168.2.200'
+M_POST = 27017
+M_USER = 'kaiyou'
+M_DB = 'kaiyou'
+M_PASSWORD = 'kaiyou'
 
-# POST_HOST = 'localhost'
-# POST_DATABASE = 'postgres'
-# POST_USER = 'postgres'
-# POST_PORT = '5433'
-# POST_PASSWORD = '123456'
-
-# 以后解开这个位置的注释
-# POST_HOST = '172.17.0.4'
-# POST_DATABASE = 'kaiyou'
-# POST_USER = 'kaiyou'
-# POST_PORT = '5432'
-# POST_PASSWORD = 'yjkj8888'
-
-
-# POST_HOST = '192.168.2.200'
-# POST_DATABASE = 'kaiyou'
-# POST_USER = 'kaiyou'
-# POST_PORT = '10432'
-# POST_PASSWORD = '123456'
-
-# R_HOST = '192.168.2.200'
-# R_POST = '6379'
-# R_PASSWORD = '123456'
-#
+LEAGUE_URL = 'http://stadmin.bocai108.com/setLeague'
+MATCH_URL = 'http://stadmin.bocai108.com/setMatch'
+ODDS_URL = 'http://stadmin.bocai108.com/setOdds'
+TOKEN_URL = "http://stadmin.bocai108.com/getToken"
+MATCH_RESULT = "http://stadmin.bocai108.com/setMatchResult"
 # POST_HOST = 'localhost'
 # POST_DATABASE = 'kaiyou'
 # POST_USER = 'kaiyou'
@@ -187,12 +168,12 @@ REDIRECT_ENABLED = False
 # REDIS_PORT = 6379
 # REDIS_PARAMS = {'password': 123456, 'db': 1}
 # 随机等待
-RANDOMIZE_DOWNLOAD_DELAY = True
-# AutoThrottle扩展
-AUTOTHROTTLE_ENABLED = True
-AUTOTHROTTLE_DEBUG = True
-AUTOTHROTTLE_TARGET_CONCURRENCY = 0.5
-AUTOTHROTTLE_MAX_DELAY = 60
+# RANDOMIZE_DOWNLOAD_DELAY = True
+# # AutoThrottle扩展
+# AUTOTHROTTLE_ENABLED = True
+# AUTOTHROTTLE_DEBUG = True
+# AUTOTHROTTLE_TARGET_CONCURRENCY = 0.25
+# AUTOTHROTTLE_MAX_DELAY = 5
 # SCHEDULER = "scrapy_redis.scheduler.Scheduler"
 # DUPEFILTER_CLASS = "scrapy_redis.dupefilter.RFPDupeFilter"
 # REDIS_URL = 'redis://:123456@192.168.2.200:6379'

+ 4 - 4
hg3535/spiders/guanjun.py

@@ -3,18 +3,18 @@
 import datetime
 import json
 
-# import scrapy
+import scrapy
 from scrapy.http import Request
 
 from .. items import Guanjun
-from scrapy_redis.spiders import RedisSpider
+# from scrapy_redis.spiders import RedisSpider
 
 
-class LqguanjunSpider(RedisSpider):
+class LqguanjunSpider(scrapy.Spider):
     name = 'guanjun'
     allowed_domains = ['hg3535z.com']
     to_day = datetime.datetime.now()
-    redis_key = "guanjun: start_urls"
+    # redis_key = "guanjun: start_urls"
     custom_settings = {
         "ITEM_PIPELINES": {
             'hg3535.pipeline.guanjun.Guanjunpipeline': 300,

+ 1 - 1
hg3535/spiders/roll_bangqiu.py

@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 import datetime
 
-import jsonpath
+# import jsonpath
 
 __author__ = 'ethereal'
 __mtime__ = '2019/4/16'

+ 1 - 13
hg3535/spiders/roll_zuqiu.py

@@ -3,7 +3,7 @@ import copy
 import datetime
 import json
 
-import jsonpath
+# import jsonpath
 import scrapy
 from scrapy.http import Request
 
@@ -25,18 +25,6 @@ class ZuqiuSpider(scrapy.Spider):
 
     def parse(self, response):
         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:

+ 13 - 2
hg3535/utils/helper.py

@@ -9,15 +9,26 @@ class Helper(object):
     def async_post(url, params):
         try:
             fs_session = FuturesSession()
-            data = fs_session.post(url, data={"data": json.dumps(params), "token": "JlUo1415650051585d481566c10c9"}, timeout=30).result()
+            data = fs_session.post(url, data={"data": json.dumps(params), "token": "u4Gdf015662654065d5b503ea2517"}, timeout=30).result()
             if data:
                 return data.content.decode('utf-8')
         except requests.exceptions.RequestException as e:
             print(e)
 
     @staticmethod
-    def genearte_MD5(params):
+    def genearte_MD5(params, pt):
         # 创建md5对象
+        hl = hashlib.md5()
+        pn = int(pt)
+        if pn == 3:
+            param = params + str(pt)
+        else:
+            param = params
+        hl.update(param.encode(encoding='utf-8'))
+        return hl.hexdigest()
+
+    @staticmethod
+    def genearte_uuid(params):
         hl = hashlib.md5()
         hl.update(params.encode(encoding='utf-8'))
         return hl.hexdigest()