init
This commit is contained in:
55
main.py
Normal file
55
main.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import io
|
||||
import oss2
|
||||
import requests
|
||||
|
||||
from PIL import Image, ImageFile
|
||||
|
||||
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
||||
|
||||
# 下载图片(使用OSS下载)
|
||||
def download_image(url:str) -> Image:
|
||||
if url.startswith('http://image.gameuiux.cn/') or url.startswith('https://image.gameuiux.cn/'):
|
||||
try:
|
||||
url = url.replace('http://image.gameuiux.cn/', '').replace('https://image.gameuiux.cn/', '')
|
||||
oss2.defaults.connection_pool_size = 100
|
||||
oss_host = 'oss-cn-shanghai-internal.aliyuncs.com'
|
||||
oss_auth = oss2.Auth('LTAI4GH3qP6VA3QpmTYCgXEW', 'r2wz4bJty8iYfGIcFmEqlY1yon2Ruy')
|
||||
return Image.open(io.BytesIO(oss2.Bucket(oss_auth, f'http://{oss_host}', 'gameui-image2').get_object(url).read()))
|
||||
except Exception:
|
||||
return None
|
||||
else:
|
||||
try:
|
||||
response = requests.get(url)
|
||||
return Image.open(io.BytesIO(response.content))
|
||||
except Exception:
|
||||
print('图片下载失败:', url)
|
||||
return None
|
||||
|
||||
|
||||
import pymysql
|
||||
import pymysql.cursors
|
||||
|
||||
conn = pymysql.connect(host='172.21.216.35', user='gameui', password='gameui@2022', database='gameui', cursorclass=pymysql.cursors.DictCursor)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT id, content FROM web_images LIMIT 10")
|
||||
|
||||
# 获取查询结果
|
||||
rows = cursor.fetchall()
|
||||
for row in rows:
|
||||
print(row)
|
||||
image = download_image(row.content)
|
||||
|
||||
# 关闭游标和连接
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
|
||||
'''
|
||||
from cnocr import CnOcr
|
||||
|
||||
img_fp = './x.jpg'
|
||||
ocr = CnOcr(rec_model_name='ch_PP-OCRv3') # 所有参数都使用默认值
|
||||
out = ocr.ocr(img_fp)
|
||||
|
||||
print(out)
|
||||
'''
|
72
requirements.txt
Normal file
72
requirements.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
attrs==23.1.0
|
||||
Automat==20.2.0
|
||||
bcrypt==3.2.0
|
||||
blinker==1.4
|
||||
certifi==2023.7.22
|
||||
chardet==4.0.0
|
||||
charset-normalizer==3.2.0
|
||||
click==8.0.3
|
||||
cloud-init==19.1.23
|
||||
colorama==0.4.4
|
||||
command-not-found==0.3
|
||||
configobj==5.0.8
|
||||
constantly==15.1.0
|
||||
cryptography==3.4.8
|
||||
dbus-python==1.2.18
|
||||
decorator==4.4.2
|
||||
distro==1.7.0
|
||||
distro-info==1.1+ubuntu0.1
|
||||
httplib2==0.20.2
|
||||
hyperlink==21.0.0
|
||||
idna==3.3
|
||||
importlib-metadata==4.6.4
|
||||
incremental==21.3.0
|
||||
jeepney==0.7.1
|
||||
Jinja2==3.1.2
|
||||
jsonpatch==1.33
|
||||
jsonpointer==2.4
|
||||
jsonschema==4.19.0
|
||||
jsonschema-specifications==2023.7.1
|
||||
keyring==23.5.0
|
||||
launchpadlib==1.10.16
|
||||
lazr.restfulclient==0.14.4
|
||||
lazr.uri==1.0.6
|
||||
MarkupSafe==2.1.3
|
||||
more-itertools==8.10.0
|
||||
netifaces==0.11.0
|
||||
oauthlib==3.2.2
|
||||
pexpect==4.8.0
|
||||
ptyprocess==0.7.0
|
||||
pyasn1==0.4.8
|
||||
pyasn1-modules==0.2.1
|
||||
PyGObject==3.42.1
|
||||
PyHamcrest==2.0.2
|
||||
PyJWT==2.3.0
|
||||
pyOpenSSL==21.0.0
|
||||
pyparsing==2.4.7
|
||||
pyserial==3.5
|
||||
python-apt==2.4.0+ubuntu2
|
||||
python-debian==0.1.43+ubuntu1.1
|
||||
python-linux-procfs==0.6.3
|
||||
python-magic==0.4.24
|
||||
pyudev==0.22.0
|
||||
PyYAML==6.0.1
|
||||
referencing==0.30.2
|
||||
requests==2.31.0
|
||||
rpds-py==0.10.2
|
||||
SecretStorage==3.3.1
|
||||
service-identity==18.1.0
|
||||
six==1.16.0
|
||||
sos==4.5.6
|
||||
ssh-import-id==5.11
|
||||
systemd-python==234
|
||||
Twisted==22.1.0
|
||||
ubuntu-advantage-tools==8001
|
||||
ubuntu-drivers-common==0.0.0
|
||||
ufw==0.36.1
|
||||
unattended-upgrades==0.1
|
||||
urllib3==2.0.4
|
||||
wadllib==1.3.6
|
||||
xkit==0.0.0
|
||||
zipp==1.0.0
|
||||
zope.interface==5.4.0
|
Reference in New Issue
Block a user