kivy把py文件打包ios

问题遇到的现象和发生背景

用kivy把py文件打包ios应用,发送到这个邮箱768764994@qq.com


import sqlite3
import os
import hmac
import requests
from selenium import webdriver
from lxml import etree
import time
import hashlib
from urllib.parse import quote_plus
import base64
import json

from selenium.webdriver.common.by import By

options = webdriver.ChromeOptions()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
class Connect:
    def __init__(self, dbpath):
        self.dbpath = dbpath
        self.connect = sqlite3.connect(self.dbpath)

    def init_db(self):
        sql = '''
            create table if not exists 'notice_info'
            (
                t text,
                content text,
                href text
            )
        '''
        # self.dbpath = dbpath
        # self.connect = sqlite3.connect(self.dbpath)  # 打开或创建数据库

        c = self.connect.cursor()  # 获取游标
        c.execute(sql)  # 执行SQL语句
        self.connect.commit()  # 提交事务
        # self.connect.close()  # 关闭

    def dataExtarct(self):
        try:
            driver.get('https://www.jiucaigongshe.com/study_publish')
            driver.implicitly_wait(5)
            t = driver.find_element(By.XPATH,'//*[@id="__layout"]/div/div[2]/div/div[2]/ul/li[6]/div/section/div[1]/div/a/div[2]/div[2]').text
            title = driver.find_element(By.XPATH,'//*[@id="__layout"]/div/div[2]/div/div[2]/ul/li[6]/div/section/div[2]/div/div').text
            href = driver.find_element(By.XPATH,'//*[@id="__layout"]/div/div[2]/div/div[2]/ul/li[6]/div/section/div[3]/div/section/div/div/a').get_attribute('href')
            content = {
                "t": t,
                "title": title,
                "href": href
            }
            return content
        except:
            pass
    def insert_data(self):
        content = self.dataExtarct()
        sql = "insert into notice_info(t, content, href) values('" + content["t"] + "', '" + content["title"] + "', '" + \
              content["href"] + "');"
        c = self.connect.cursor()
        c.execute(sql)
        self.connect.commit()  # 提交事务
        # self.connect.close()  # 关闭
        self.save_data()

    def save_data(self):
        content = self.dataExtarct()
        sql = "select * from notice_info where t = '" + content["t"] + "' and  content = '" + content["title"] + "' and  href= '" + content["href"] + "';"
        # print(sql)
        self.connect = sqlite3.connect(self.dbpath)  # 打开或创建数据库
        c = self.connect.cursor()  # 获取游标
        cursor = c.execute(sql)  # 执行SQL语句
        result = 0
        for row in cursor:
            print(row)
            result += 1
        if result == 0:
            self.insert_data()
            # 如果数据库中没有记录的话,那么就发送这条消息
            m = Messenger(
                token="e2ddba004b474ffae7087f4ddea27fb2455a0f55f78c4f63b62c35a9ef51d026",
                secret="SECd072c9f0c2c0d8103c36ef3481162c6256f581abbafbfd4d5683ad224a9f4a88"
            )
            m.send_text(content["title"])

            return 1
        else:
            return 0


class Messenger:
    def __init__(self, token=os.getenv("DD_ACCESS_TOKEN"), secret=os.getenv("DD_SECRET")):
        self.timestamp = str(round(time.time() * 1000))
        self.URL = "https://oapi.dingtalk.com/robot/send"
        self.headers = {'Content-Type': 'application/json'}
        secret = secret
        secret_enc = secret.encode('utf-8')
        string_to_sign = '{}\n{}'.format(self.timestamp, secret)
        string_to_sign_enc = string_to_sign.encode('utf-8')
        hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
        self.sign = quote_plus(base64.b64encode(hmac_code))
        self.params = {'access_token': token, "sign": self.sign}

    def send_text(self, content):
        """
        发送文本
        @param content: str, 文本内容
        """
        data = {"msgtype": "text", "text": {"content": content}}
        self.params["timestamp"] = self.timestamp
        return requests.post(
            url=self.URL,
            data=json.dumps(data),
            params=self.params,
            headers=self.headers
        )

while True:
    connect = Connect('mydata.sqlite')
    connect.init_db()
    connect.save_data()
    time.sleep(5)