@@ -0,0 +1,6 @@
|
||||
/database
|
||||
/images
|
||||
.git
|
||||
.vscode
|
||||
.htaccess
|
||||
.DS_Store
|
||||
@@ -0,0 +1,78 @@
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from threading import Timer
|
||||
|
||||
if not os.path.exists("database/"):
|
||||
os.makedirs("database/")
|
||||
|
||||
if not os.path.exists("images/"):
|
||||
os.makedirs("images/")
|
||||
|
||||
NS_id='15558'
|
||||
PS5_id='15791'
|
||||
PS4_id='11591'
|
||||
|
||||
url='https://853life.com/api/'
|
||||
data={
|
||||
'todo':'get_category',
|
||||
'now_domain': '853life.com',
|
||||
'category_id':'15558',
|
||||
'item_type':'0',
|
||||
}
|
||||
|
||||
def getdata(tyhpe):
|
||||
data['category_id']=tyhpe
|
||||
r=requests.post(url,data)
|
||||
if(r.status_code==200):
|
||||
htmlx=r.content
|
||||
htmlx=str(htmlx,'utf-8')
|
||||
#htmlx=htmlx.encode('utf-8').decode('unicode_escape')
|
||||
jsdata=json.loads(htmlx)
|
||||
for i in jsdata['item_list']:
|
||||
local_image="images/"+i['main_photo']
|
||||
if not os.path.isfile(local_image):
|
||||
image_url="https://images.cube.mo/items/"+i['main_photo']
|
||||
downloadimage=requests.get(image_url)
|
||||
print("try download image:"+image_url)
|
||||
if downloadimage.status_code==200:
|
||||
image_f=open(local_image,"wb")
|
||||
image_f.write(downloadimage.content)
|
||||
image_f.close
|
||||
else:
|
||||
print("have image: "+local_image)
|
||||
|
||||
jsdump=json.dumps(jsdata,ensure_ascii=False, indent=4, separators=(',', ': '))
|
||||
return jsdump
|
||||
#print(jsdump)
|
||||
#f=open("database/switch_"+str(int(time.time()))+".json","w",encoding='utf8')
|
||||
#f.write(jsdump)
|
||||
#f.close
|
||||
#print("saved")
|
||||
|
||||
|
||||
def runaway():
|
||||
f=open("database/switch_"+str(int(time.time()))+".json","w",encoding='utf8')
|
||||
f.write(getdata(NS_id))
|
||||
f.close
|
||||
print("NS_saved")
|
||||
|
||||
f=open("database/ps5_"+str(int(time.time()))+".json","w",encoding='utf8')
|
||||
f.write(getdata(PS5_id))
|
||||
f.close
|
||||
print("PS5_saved")
|
||||
|
||||
f=open("database/ps4_"+str(int(time.time()))+".json","w",encoding='utf8')
|
||||
f.write(getdata(PS4_id))
|
||||
f.close
|
||||
print("PS4_saved")
|
||||
|
||||
t = Timer(600.0, runaway)
|
||||
t.start()
|
||||
|
||||
print("with 10 min")
|
||||
|
||||
|
||||
t = Timer(1.0, runaway)
|
||||
t.start()
|
||||
@@ -0,0 +1,17 @@
|
||||
import json
|
||||
import re
|
||||
f=open("database/switch_1687967369.json",'r',encoding='utf8')
|
||||
|
||||
|
||||
jsdata=json.loads(f.read())
|
||||
#https://images.cube.mo/items/4131cube_41312023-01-20-17-10-35888.png
|
||||
|
||||
for i in jsdata['item_list']:
|
||||
print(i['item_name'])
|
||||
print("SUK: "+i['item_no'])
|
||||
print(i['nowprice']+"MOP")
|
||||
print("发售日期:"+i['salestart'])
|
||||
stock=re.findall("[0-9]+",i['stock_text'])[0]
|
||||
print("参考库存:"+stock)
|
||||
print(i['main_photo'])
|
||||
print()
|
||||
Reference in New Issue
Block a user