1 Star 0 Fork 0

emoji/py

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
more_emo.py 2.33 KB
一键复制 编辑 原始数据 按行查看 历史
liuqiba 提交于 2022-08-07 22:27 . daoli
# -*- coding: utf-8 -*-
# @Author : Lny
# @Email : 2635214715@qq.com
# @Site : http://www.qqlove.pro
# @Time : 2022-07-11 11:51:09
# @Desc :
from lxml import etree
import time
import uuid
import requests
import datetime
import qi_niu
import os
import emodb.db
import random
header = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
# 'Referer': 'https://pic.sogou.com/pic/emo/searchList.jsp',
# 'Host': 'pic.sogou.com'
}
# https://pic.sogou.com/napi/wap/emoji/moreEmo?start=4557&len=50
num = 1267
for i in range(4557):
url = "https://pic.sogou.com/napi/wap/emoji/moreEmo?start="+str(i)+"&len=1"
json = requests.get(url=url, headers=header).json()
# if not json['data']:
# data = json['data'][0]
if json['data']:
data = json['data'][0]
select_sql = """SELECT * FROM `emo_group` WHERE source_id = '%s'""" % data['groupId']
select_group_res = emodb.db.DataBase().select_data(select_sql)
if not select_group_res:
now_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# 随机获取一个user_uuid
# rand_user_uuid_sql = """SELECT `uuid` FROM emo_user ORDER BY RAND() LIMIT 1"""
# user_uuid = emodb.db.DataBase().select_data(rand_user_uuid_sql)
# 随机获取一个category_uuid
rand_user_uuid_sql = """SELECT `uuid` FROM emo_category ORDER BY RAND() LIMIT 1"""
category_uuid = emodb.db.DataBase().select_data(rand_user_uuid_sql)
sql = """insert into emo_group (uuid,category_uuid,title,views,count,source_id,source_url,created_at,updated_at) values('%s','%s','%s','%s','%s','%s','%s','%s','%s')""" % (
uuid.uuid4(),
category_uuid[0][0],
data['groupName'],
random.randint(999, 9999),
data['count'],
data['groupId'],
'pic.sogou.com',
now_time,
now_time)
emodb.db.DataBase().insert_data(sql)
print(data['groupId'])
# select_sql = """SELECT * FROM `emo_image_group` WHERE id = '5764'"""
# select_group_res = emodb.db.DataBase().select_data(select_sql)
# if not select_group_res:
# print(1)
# else:
# print(2.txt)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/emoji_1/py.git
git@gitee.com:emoji_1/py.git
emoji_1
py
py
master

搜索帮助