1 Star 0 Fork 2

星痕/NewBee批量上架

forked from zzZ/NewBee批量上架 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 26.79 KB
一键复制 编辑 原始数据 按行查看 历史
zzZ 提交于 2024-06-06 11:18 . 更新2.1版本,增加元素批量上架
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'test.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import json
import time
import datetime
import requests
import threading
from PyQt5 import QtCore, QtWidgets
from urllib.parse import quote
from log import logger
from util import get_random_useragent_phone, get_time_stamp13, get_md5
class Ui_Form(object):
def __init__(self):
self.user_agent = get_random_useragent_phone()
self.sess = requests.session()
# 软件许可标志位
self.activationStatus = False
# 藏品ID列表
self.commodityIdList = list()
self.productTypeList = list()
# 子线程结束标志
self.stopEvent = threading.Event()
self.stopEvent.clear()
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(902, 571)
self.logTextBrowser = QtWidgets.QTextBrowser(Form)
self.logTextBrowser.setGeometry(QtCore.QRect(30, 200, 841, 351))
self.logTextBrowser.setObjectName("logTextBrowser")
self.groupBox_2 = QtWidgets.QGroupBox(Form)
self.groupBox_2.setGeometry(QtCore.QRect(30, 30, 401, 151))
self.groupBox_2.setObjectName("groupBox_2")
self.loginButton = QtWidgets.QPushButton(self.groupBox_2)
self.loginButton.setGeometry(QtCore.QRect(290, 20, 93, 28))
self.loginButton.setObjectName("loginButton")
self.loginButton.clicked.connect(lambda: self.thread_it(self.LoginClick))
self.phoneLabel = QtWidgets.QLabel(self.groupBox_2)
self.phoneLabel.setGeometry(QtCore.QRect(20, 20, 41, 31))
self.phoneLabel.setObjectName("phoneLabel")
self.phoneLineEdit = QtWidgets.QLineEdit(self.groupBox_2)
self.phoneLineEdit.setGeometry(QtCore.QRect(80, 20, 201, 31))
self.phoneLineEdit.setObjectName("phoneLineEdit")
self.passwordLabel = QtWidgets.QLabel(self.groupBox_2)
self.passwordLabel.setGeometry(QtCore.QRect(20, 60, 41, 31))
self.passwordLabel.setObjectName("passwordLabel")
self.PasswordLineEdit = QtWidgets.QLineEdit(self.groupBox_2)
self.PasswordLineEdit.setGeometry(QtCore.QRect(80, 60, 201, 31))
self.PasswordLineEdit.setObjectName("PasswordLineEdit")
self.tokenLabel = QtWidgets.QLabel(self.groupBox_2)
self.tokenLabel.setGeometry(QtCore.QRect(10, 100, 51, 31))
self.tokenLabel.setObjectName("tokenLabel")
self.tokenLineEdit = QtWidgets.QLineEdit(self.groupBox_2)
self.tokenLineEdit.setGeometry(QtCore.QRect(80, 100, 201, 31))
self.tokenLineEdit.setObjectName("tokenLineEdit")
self.startSaleButton = QtWidgets.QPushButton(self.groupBox_2)
self.startSaleButton.setGeometry(QtCore.QRect(290, 60, 93, 28))
self.startSaleButton.setObjectName("startSaleButton")
self.startSaleButton.clicked.connect(lambda: self.thread_it(self.StartSaleClick))
self.salePasswordLineEdit = QtWidgets.QLineEdit(self.groupBox_2)
self.salePasswordLineEdit.setGeometry(QtCore.QRect(290, 100, 91, 31))
self.salePasswordLineEdit.setObjectName("salePasswordLineEdit")
self.groupBox_3 = QtWidgets.QGroupBox(Form)
self.groupBox_3.setGeometry(QtCore.QRect(470, 30, 401, 151))
self.groupBox_3.setObjectName("groupBox_3")
self.selectComboBox = QtWidgets.QComboBox(self.groupBox_3)
self.selectComboBox.setGeometry(QtCore.QRect(70, 20, 201, 31))
self.selectComboBox.setObjectName("selectComboBox")
self.selectSeriesButton = QtWidgets.QPushButton(self.groupBox_3)
self.selectSeriesButton.setGeometry(QtCore.QRect(290, 60, 101, 31))
self.selectSeriesButton.setObjectName("selectSeriesButton")
self.selectSeriesButton.clicked.connect(lambda: self.thread_it(self.SelectCommodityClick))
self.selectLabel = QtWidgets.QLabel(self.groupBox_3)
self.selectLabel.setGeometry(QtCore.QRect(10, 20, 41, 31))
self.selectLabel.setObjectName("selectLabel")
# self.searchLineEdit = QtWidgets.QLineEdit(self.groupBox_3)
# self.searchLineEdit.setGeometry(QtCore.QRect(290, 20, 101, 31))
# self.searchLineEdit.setObjectName("searchLineEdit")
self.stopButton = QtWidgets.QPushButton(self.groupBox_3)
self.stopButton.setGeometry(QtCore.QRect(290, 20, 101, 31))
self.stopButton.setObjectName("stopButton")
self.stopButton.clicked.connect(lambda: self.thread_it(self.StopClick))
self.saleNumLineEdit = QtWidgets.QLineEdit(self.groupBox_3)
self.saleNumLineEdit.setGeometry(QtCore.QRect(70, 60, 201, 31))
self.saleNumLineEdit.setObjectName("saleNumLineEdit")
self.saleNumLabel = QtWidgets.QLabel(self.groupBox_3)
self.saleNumLabel.setGeometry(QtCore.QRect(10, 60, 41, 31))
self.saleNumLabel.setObjectName("saleNumLabel")
self.salePriceLineEdit = QtWidgets.QLineEdit(self.groupBox_3)
self.salePriceLineEdit.setGeometry(QtCore.QRect(70, 100, 201, 31))
self.salePriceLineEdit.setObjectName("salePriceLineEdit")
self.salePriceLabel = QtWidgets.QLabel(self.groupBox_3)
self.salePriceLabel.setGeometry(QtCore.QRect(10, 100, 41, 31))
self.salePriceLabel.setObjectName("salePriceLabel")
self.selectMySeriesButton = QtWidgets.QPushButton(self.groupBox_3)
self.selectMySeriesButton.setGeometry(QtCore.QRect(290, 100, 101, 31))
self.selectMySeriesButton.setObjectName("selectMySeriesButton")
self.selectMySeriesButton.clicked.connect(lambda: self.thread_it(self.SelectMyCommodityClick))
self.groupBox_2.raise_()
self.groupBox_3.raise_()
self.logTextBrowser.raise_()
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
self.ActivationLoginClick()
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "zzZ寄售小助手 本软件免费开源,问题及优化建议 QQ群:905842745"))
self.groupBox_2.setTitle(_translate("Form", "账号登录"))
self.loginButton.setText(_translate("Form", "登录"))
self.phoneLabel.setText(_translate("Form", "账号:"))
self.phoneLineEdit.setPlaceholderText(_translate("Form", "输入账号或手机号"))
self.passwordLabel.setText(_translate("Form", "密码:"))
self.PasswordLineEdit.setPlaceholderText(_translate("Form", "输入密码或验证码"))
self.tokenLabel.setText(_translate("Form", "token:"))
self.tokenLineEdit.setPlaceholderText(_translate("Form", "输入token无需点击登录"))
self.startSaleButton.setText(_translate("Form", "开始挂售"))
self.salePasswordLineEdit.setPlaceholderText(_translate("Form", "输入寄售密码"))
self.groupBox_3.setTitle(_translate("Form", "挂售"))
self.selectSeriesButton.setText(_translate("Form", "查询我的藏品"))
self.selectLabel.setText(_translate("Form", "藏品:"))
# self.searchLineEdit.setPlaceholderText(_translate("Form", "藏品关键词"))
self.stopButton.setText(_translate("Form", "结束挂售"))
self.saleNumLineEdit.setPlaceholderText(_translate("Form", "输入想要挂售的数量"))
self.saleNumLabel.setText(_translate("Form", "数量:"))
self.salePriceLineEdit.setPlaceholderText(_translate("Form", "输入挂售的价格"))
self.salePriceLabel.setText(_translate("Form", "价格:"))
self.selectMySeriesButton.setText(_translate("Form", "暂未启用"))
def thread_it(self, func, *args):
"""打包线程"""
t = threading.Thread(target=func, args=args)
t.setDaemon(True)
t.start()
def printf(self, level, message):
"""
向日志文本框中记录日志信息
:param level: 日志等级,1为INFO,其余为ERROR
:param message: 日志信息
"""
if int(level) == 1:
level = 'INFO'
logger.info(message)
else:
level = 'ERROR'
logger.error(message)
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
log_entry = f"{timestamp}\t{level}: {message}"
self.logTextBrowser.append(log_entry) # 在指定的区域显示日志信息
cursor = self.logTextBrowser.textCursor()
self.logTextBrowser.moveCursor(cursor.End)
QtWidgets.QApplication.processEvents()
def ActivationLoginClick(self):
"""软件激活事件"""
if self.activationStatus:
self.printf(1, "请勿重复激活")
# self.statusLabel.setText("授权状态: 已授权")
# self.timer.start(100)
return
# self.printf(1, "系统环境检测中,请稍等")
# if self.CheckCaptureProcess():
# sys.exit()
activationCode = ""
url = 'http://124.220.169.77:5000/activationOrder'
headers = {
'User-Agent': self.user_agent,
'Content-Type': 'application/json',
}
data = {"activationCode": activationCode}
data = json.dumps(data)
try:
resp = self.sess.post(url=url, headers=headers, data=data)
resp_json = json.loads(resp.text)
if resp_json["code"] == 1:
self.activationStatus = True
# self.statusLabel.setText("授权状态: 已授权")
self.printf(1, resp_json["msg"])
self.printf(1, "当前合成元素批量上架卡价格300元,数藏无情人有爱,本软件免费开源若您发现有人用本软件牟利请及时举报")
# self.timer.start(100)
return
else:
self.activationStatus = False
# self.statusLabel.setText("授权状态: 未授权")
self.printf(0, resp_json["msg"])
return
except Exception as e:
self.printf(0, "服务器关闭或激活码失效")
return
def LoginClick(self):
"""登录事件"""
if not self.activationStatus:
return
phone = self.phoneLineEdit.text()
password = self.PasswordLineEdit.text()
slideDict = self.GetCode()
captcha = self.PassSlide(slideDict["imgBase64"])
slideId = slideDict["slideId"]
token = self.SubmitLogin(phone, password, captcha, slideId)
self.tokenLineEdit.setText(token)
return
def StopClick(self):
"""结束线程事件"""
self.stopEvent.set()
return
def SelectCommodityClick(self):
"""查询绘画区藏品事件"""
if not self.activationStatus:
return
token = self.tokenLineEdit.text()
commodityNameList = self.SelectCommodity(token, 0)
if len(commodityNameList) != 0:
self.selectComboBox.clear()
self.selectComboBox.addItems(commodityNameList)
return
def SelectMyCommodityClick(self):
"""查询我拥有的藏品Id(查询建模区藏品事件)"""
if not self.activationStatus:
return
# token = self.tokenLineEdit.text()
# commodityNameList = self.SelectCommodity(token, 1)
# if len(commodityNameList) != 0:
# self.selectComboBox.clear()
# self.selectComboBox.addItems(commodityNameList)
return
def StartSaleClick(self):
"""开始挂售事件"""
if not self.activationStatus:
return
self.stopEvent.clear()
token = self.tokenLineEdit.text()
index = self.selectComboBox.currentIndex()
commodityId = self.commodityIdList[index]
salePrice = self.salePriceLineEdit.text()
saleNum = int(self.saleNumLineEdit.text())
password = self.salePasswordLineEdit.text()
if self.productTypeList[index] == "绘画":
type = 0
elif self.productTypeList[index] == "建模":
type = 1
if self.productTypeList[index] != "元素":
saleItemIdList, saleSnList, saleCidList = [], [], []
page = 1
while True:
itemIdList,snList,cidList,status = self.SelectMyCommodity(token, commodityId, page, type)
saleItemIdList += itemIdList
saleSnList += snList
saleCidList += cidList
page += 1
if len(saleItemIdList) >= saleNum:
break
if not status:
break
time.sleep(0.4)
if len(saleItemIdList) < saleNum:
saleNum = len(saleItemIdList)
for i in range(saleNum):
if self.stopEvent.is_set():
self.printf(1, "线程结束")
return
self.SubmitSale(token, commodityId, salePrice, saleCidList[i], saleItemIdList[i], saleSnList[i], password)
# self.printf(1, "当前进度: {} / {}".format(i+1, saleNum))
time.sleep(2)
else:
quotient = saleNum // 10
remainder = saleNum % 10
if quotient > 0:
for i in range(quotient):
if self.stopEvent.is_set():
self.printf(1, "线程结束")
return
self.SubmitSaleElement(token, commodityId, salePrice, 10, password)
time.sleep(2)
if remainder > 0:
self.SubmitSaleElement(token, commodityId, salePrice, remainder, password)
else:
if remainder > 0:
self.SubmitSaleElement(token, commodityId, salePrice, remainder, password)
def GetCode(self):
"""获取验证码"""
timestamp = get_time_stamp13()
url = "https://api.huancang.art/api/sms/getCode?timestamp={}".format(timestamp)
signatureData = "api/sms/getcode?timestamp={}&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(timestamp)
signature = get_md5(signatureData)
headers = {
"user-agent": self.user_agent,
"Signature": "2bd17b71495819c32b37b39388bcb2ac",
"Token": "",
"X-Token": signature
}
resp = self.sess.get(url=url, headers=headers)
resp_json = json.loads(resp.text)
slideDict = {}
if resp_json["code"] == 1:
slideDict["imgBase64"] = resp_json["data"]["base64"].split(",")[1]
slideDict["slideId"] = resp_json["data"]["id"]
self.printf(1, "验证码获取成功")
return slideDict
else:
msg = resp_json["msg"]
self.printf(0, "验证码获取失败: {}".format(msg))
return slideDict
def PassSlide(self, imgBase64):
"""识别验证码"""
url = "http://124.220.169.77:5000/passSlideNewBee"
headers = {
"User-Agent":self.user_agent,
'Content-Type': 'application/json'
}
data = {"imgBase64":imgBase64}
data = json.dumps(data)
resp = self.sess.post(url=url, headers=headers, data=data)
resp_json = json.loads(resp.text)
if resp_json["code"] == 1:
captcha = resp_json["result"]
self.printf(1, "验证码识别成功: {}".format(captcha))
return captcha
def SubmitLogin(self, phone, password, captcha, slideId):
"""
账号登陆
:param phone账号
:param password密码/验证码
:return token账户令牌
"""
url = "https://api.huancang.art/api/user/login"
timestamp = get_time_stamp13()
signatureData = "api/user/login?captcha={}&id={}&mobile={}&password={}&timestamp={}&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(captcha, slideId, phone, password, timestamp)
signature = get_md5(signatureData)
headers = {
"user-agent": self.user_agent,
"Content-Type": "application/json",
"Signature": "2bd17b71495819c32b37b39388bcb2ac",
"Token": "",
"X-Token": signature
}
data = {
"captcha": captcha,
"id": slideId,
"mobile": phone,
"password": password,
"timestamp": timestamp
}
data = json.dumps(data)
resp = self.sess.post(url=url, headers=headers, data=data)
resp_json = json.loads(resp.text)
token = None
if resp_json["code"] == 1:
token = resp_json["data"]["userinfo"]["token"]
userId = resp_json["data"]["userinfo"]["user_id"]
self.userId = userId
self.printf(1, "登录成功,token: {}".format(token))
return token
else:
msg = resp_json["msg"]
self.printf(0, "登录失败: {}".format(msg))
return token
def SubmitSale(self, token, commodityId, price, cid, itemId, sn, password):
"""上架挂售"""
url = "https://api.huancang.art/api/user_collect/onSaleNew"
timestamp = get_time_stamp13()
signatureData = "api/user_collect/onsalenew?amount={}&cid={}&item_id={}&pay_password={}&paytypes=140,121&product_id={}&sn={}&timestamp={}&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(price,cid,itemId,password,commodityId,sn,timestamp)
signature = get_md5(signatureData)
headers = {
"user-agent": self.user_agent,
"Content-Type": "application/json",
"Signature": "2bd17b71495819c32b37b39388bcb2ac",
"Token": token,
"X-Token": signature
}
data = {
"amount": price,
"cid": cid,
"item_id": itemId,
"pay_password": password,
"paytypes": "140,121",
"product_id": commodityId,
"sn": sn,
"timestamp": timestamp
}
data = json.dumps(data)
resp = self.sess.post(url=url, headers=headers, data=data)
resp_json = json.loads(resp.text)
if resp_json["code"] == 1:
self.printf(1, "挂售成功")
return True
else:
msg = resp_json["msg"]
self.printf(0, "挂售失败: {}".format(msg))
return False
def SubmitSaleElement(self, token, commodityId, price, saleNum, password):
"""上架挂售元素"""
url = "https://api.huancang.art/api/market_collect/sale"
timestamp = get_time_stamp13()
signatureData = f"api/market_collect/sale?amount={price}&num={saleNum}&pay_password={password}&paytypes=140&product_id={commodityId}&timestamp={timestamp}&key=6rnrdpjjv6wz2sspxqeibesov1itxddc"
signature = get_md5(signatureData)
headers = {
"user-agent": self.user_agent,
"Content-Type": "application/json",
"Signature": "2bd17b71495819c32b37b39388bcb2ac",
"Token": token,
"X-Token": signature
}
data = {
"amount": price,
"num": saleNum,
"pay_password": password,
"paytypes": 140,
"product_id": commodityId,
"timestamp": timestamp
}
data = json.dumps(data)
resp = self.sess.post(url=url, headers=headers, data=data)
resp_json = json.loads(resp.text)
if resp_json["code"] == 1:
self.printf(1, "挂售成功")
return True
else:
msg = resp_json["msg"]
self.printf(0, "挂售失败: {}".format(msg))
return False
def SelectMyCommodity(self, token, seriesId, page, type):
"""
查询我拥有的藏品ID
"""
timestamp = get_time_stamp13()
if int(type) == 0:
signatureData = "api/user_collect?page={}&per_page={}&product_id={}&timestamp={}&type=own_valid&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(
page, 30, seriesId, timestamp)
url = "https://api.huancang.art/api/user_collect?page={}&per_page={}&product_id={}&timestamp={}&type=own_valid".format(
page, 30, seriesId, timestamp)
else:
signatureData = "api/user_collect?page={}&per_page={}&product_id={}&product_type=modeling&timestamp={}&type=own_valid&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(
page, 30, seriesId, timestamp)
url = "https://api.huancang.art/api/user_collect?page={}&per_page={}&product_id={}&product_type=modeling&timestamp={}&type=own_valid".format(
page, 30, seriesId, timestamp)
signature = get_md5(signatureData)
headers = {
"user-agent": self.user_agent,
"Content-Type": "application/json",
"Signature": "2bd17b71495819c32b37b39388bcb2ac",
"Token": token,
"X-Token": signature
}
itemIdList = []
snList = []
cidList = []
status = True
try:
resp = self.sess.get(url=url, headers=headers)
resp_json = json.loads(resp.text)
if resp_json["code"] == 1:
productList = resp_json["data"]["data"]
if len(productList) == 0:
status = False
return itemIdList,snList,cidList,status
for i in range(len(productList)):
cid = productList[i]["id"]
itemId = productList[i]["item_id"]
sn = productList[i]["item"]["sn"]
status = int(productList[i]["status"])
if status == 2:
itemIdList.append(itemId)
snList.append(sn)
cidList.append(cid)
self.printf(1, "我拥有的藏品ID信息查询成功")
return itemIdList,snList,cidList,status
else:
msg = resp_json["msg"]
self.printf(0, "我拥有的藏品ID信息查询失败: {}".format(msg))
return itemIdList,snList,cidList,status
except Exception as e:
self.printf(0, e)
return itemIdList,snList,cidList,status
def SelectCommodity(self, token, type):
"""
查询藏品
:param token用户令牌
:param type藏品类型绘画/建模
:return commodityList藏品名列表
"""
self.commodityIdList.clear()
self.productTypeList.clear()
commodityNameList = list()
for i in range(3):
timestamp = get_time_stamp13()
if i == 0:
signatureData = "api/user_collect/getalbumlistv2?page=1&per_page=50&timestamp={}&type=own_valid&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(timestamp)
url = "https://api.huancang.art/api/user_collect/getAlbumListV2?page=1&per_page=50&timestamp={}&type=own_valid".format(timestamp)
elif i == 1:
signatureData = "api/user_collect/getalbumlistv2?page=1&per_page=50&prodcut_type=modeling&timestamp={}&type=own_valid&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(timestamp)
url = "https://api.huancang.art/api/user_collect/getAlbumListV2?page=1&per_page=50&prodcut_type=modeling&timestamp={}&type=own_valid".format(timestamp)
elif i == 2:
signatureData = "api/user_collect/getalbumlistv2?page=1&per_page=50&prodcut_type=digital&timestamp={}&type=own_valid&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(timestamp)
url = "https://api.huancang.art/api/user_collect/getAlbumListV2?page=1&per_page=50&prodcut_type=digital&timestamp={}&type=own_valid".format(timestamp)
signature = get_md5(signatureData)
headers = {
"user-agent": self.user_agent,
"Signature": "2bd17b71495819c32b37b39388bcb2ac",
"Token": token,
"X-Token": signature
}
commodityNameList_ = list()
try:
resp = self.sess.get(url=url, headers=headers)
resp_json = json.loads(resp.text)
if resp_json["code"] == 1:
album_list = resp_json["data"]["data"]
for k in range(len(album_list)):
commodityName = album_list[k].get("subject")
commodityId = album_list[k].get("id")
commodityNameList_.append(commodityName)
self.commodityIdList.append(commodityId)
if i == 0:
self.productTypeList.append("绘画")
elif i == 1:
self.productTypeList.append("建模")
elif i == 2:
self.productTypeList.append("元素")
self.printf(1, "藏品信息查询成功")
commodityNameList += commodityNameList_
else:
msg = resp_json["msg"]
self.printf(0, "藏品信息查询失败: {}".format(msg))
except Exception as e:
self.printf(0, e)
return commodityNameList
def SelectCommodityByKeyword(self, token, keywords):
"""
查询藏品根据关键词
:param token用户令牌
:return commodityList藏品名列表
"""
timestamp = get_time_stamp13()
signatureData = "api/v2/market/search?hasmarket=-1&hot=0&keywords={}&market_type=0&order=weigh&page=1&per_page=20&product_type=2&sort=desc&timestamp={}&key=6rnrdpjjv6wz2sspxqeibesov1itxddc".format(keywords, timestamp)
signature = get_md5(signatureData)
url = "https://api.huancang.art/api/v2/market/search?hasmarket=-1&hot=0&keywords={}&market_type=0&order=weigh&page=1&per_page=20&product_type=2&sort=DESC&timestamp={}".format(quote(keywords), timestamp)
headers = {
"user-agent": self.user_agent,
"Signature": "2bd17b71495819c32b37b39388bcb2ac",
"Token": token,
"X-Token": signature
}
commodityNameList = list()
try:
resp = self.sess.get(url=url, headers=headers)
resp_json = json.loads(resp.text)
if resp_json["code"] == 1:
self.commodityIdList.clear()
album_list = resp_json["data"]["data"]
for i in range(len(album_list)):
commodityName = album_list[i].get("subject")
commodityId = album_list[i].get("product_id")
commodityNameList.append(commodityName)
self.commodityIdList.append(commodityId)
self.printf(1, "藏品信息查询成功")
return commodityNameList
else:
msg = resp_json["msg"]
self.printf(0, "藏品信息查询失败: {}".format(msg))
return commodityNameList
except Exception as e:
self.printf(0, e)
return commodityNameList
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xing-hen/NewBee-bulk-listing.git
git@gitee.com:xing-hen/NewBee-bulk-listing.git
xing-hen
NewBee-bulk-listing
NewBee批量上架
master

搜索帮助