代码拉取完成,页面将自动刷新
# -*- 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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。