#导入包
from datetime import date
import json
import requests
import urllib
from urllib import request
import pandas as pd
url = 'http://cqzs.3cerp.com/pages/stock/searchGoodsExtendStock.htm'
cookies = {'3cu':'????'}
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0"}
x = requests.get(url=url,headers=headers,cookies=cookies,verify=False)
dict = x.json()
df2 = pd.DataFrame(dict['data'])
y = 0
L1 = ["有货且上架:"]
L2 = ["有货没上架:"]
L3 = ["无货且上架:"]
L4 = ["无货没上架:"]
while y < 4:
df1 = pd.read_excel(r"G:\ZM\sku对应表.xlsx")
#print(df1)
sku = str(df1.iloc[y,0])
one = df1.iloc[y,1]
try:
two = df1.iloc[y,2]
except:
two = 1
try:
three = df1.iloc[y,3]
except:
three = 1
try:
four = df1.iloc[y,4]
except:
four = 1
url = f'https://c0.3.cn/stocks?area=4_50952_50969_0&type=getstocks&skuIds={sku}'
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0"}
x = requests.get(url=url,headers=headers,verify=False)
#print(x)
dict = x.json()
#print(dict)
sku_stock = dict[sku]['StockStateName']
print('网店库存',sku_stock)
print(one)
print(two)
print(three)
a = df2.loc[df2['b_c_name']==f'{one}','n_stock'].values[0]
try:
b = df2.loc[df2['b_c_name']==f'{two}','n_stock'].values[0]
except:
b = 1
try:
c = df2.loc[df2['b_c_name']==f'{three}','n_stock'].values[0]
except:
c = 1
try:
d = df2.loc[df2['b_c_name']==f'{four}','n_stock'].values[0]
except:
d = 1
print('库存数',a,b,c)
y += 1
if a > 0 and b > 0 and c > 0 and d > 0 :
print("库存有货")
if sku_stock != '无货':
print("有货且上架")
L1.append(sku)
else:
print("有货没上架")
L2.append(sku)
else:
print("库存没有")
if sku_stock != '无货':
print('无货但上架')
L3.append(sku)
else:
print('无货没上架')
L4.append(sku)
Lall = L1 + L2 + L3 + L4
print(Lall)
def ding():
headers={'Content-Type': 'application/json'}
robot_url = "https://oapi.dingtalk.com/robot/send?access_token=???"
data1 ={
"at": {
"atMobiles":[
"180xxxxxx"
],
"atUserIds":[
"user123"
],
"isAtAll": False
},
"text": {
"content":f"{Lall}"
},
"msgtype":"text"
}
robot= requests.post(url = robot_url,data=json.dumps(data1),headers=headers)
print(Lall)
ding()...
版权属于:
irx999
作品采用:
《
署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
》许可协议授权
评论 (0)