179 lines
7.0 KiB
Plaintext
179 lines
7.0 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"metadata": {},
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"import requests\n",
|
|
"import json\n",
|
|
"import xlrd\n",
|
|
"import time\n",
|
|
"cookies_str = 'f6-ids-goodsSESSIONID=d7c6430c-5581-493b-b7ab-0c605c5dca86; erpLanguage=zh-CN; tmall=false; prodOrg=10545724654284683060; unp=10907434497537082431; _up=-NillNN-qyBEJ--t3vnSknvoOFt2zfaJs8kB2nw6WeBdXvPFpJjQjaZJ9Q3d-WrAAGgt60MgQHajHWBHMKKxj0CuWypi1JgKCFP1EPEk-HbqEvIRq4Ij1QAE_PJRv-ZNHu3M-GTZ15i2EXSsquRSjOgdkF7BOhBurEj94R-494y5PGg.; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2210907434497537082431%22%2C%22first_id%22%3A%221750b4690af1f6-089dd3a4874eb8-3d634f03-1327104-1750b4690b09d0%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22%24device_id%22%3A%221750b4690af1f6-089dd3a4874eb8-3d634f03-1327104-1750b4690b09d0%22%7D'\n",
|
|
"cookies_str = cookies_str.encode('utf-8').decode('latin-1')\n",
|
|
"\n",
|
|
"cookie_dict = {item.split('=')[0]: item.split('=')[1]\n",
|
|
" for item in cookies_str.split('; ')}\n",
|
|
"\n",
|
|
"headers = {\n",
|
|
" 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.40',\n",
|
|
" \"Content-Type\": \"application/json\",\n",
|
|
" 'origin': 'https://yunxiu.f6car.cn'\n",
|
|
"}\n",
|
|
"#读取excel文件\n",
|
|
"data = xlrd.open_workbook(r\"C:\\Users\\admin\\Desktop\\新建XLS 工作表 (3).xls\")\n",
|
|
"\n",
|
|
"table = data.sheet_by_index(3) # 通过索引顺序获取\n",
|
|
"\n",
|
|
"h = table.nrows\n",
|
|
"\n",
|
|
"l = table.ncols\n",
|
|
"\n",
|
|
"print(u\"表数据的行数为%s,列数为%s\"%(h,l))\n",
|
|
"\n",
|
|
"for i in range(1,h):\n",
|
|
" try:\n",
|
|
" time.sleep(0.3)\n",
|
|
" idMember =table.cell(i, 0).value #材料id\n",
|
|
" pastebin_url_json = {\n",
|
|
" \"keyWord\": \"\",\n",
|
|
" \"idOwnOrg\": \"10545724654284683060\",\n",
|
|
" \"currentPage\": 1,\n",
|
|
" \"pageSize\": 10,\n",
|
|
" \"name\": \"\",\n",
|
|
" \"brand\": \"\",\n",
|
|
" \"supplierCode\": \"\",\n",
|
|
" \"customCode\": idMember,\n",
|
|
" \"categoryName\": \"\",\n",
|
|
" \"categoryId\": \"\",\n",
|
|
" \"labelId\": \"\",\n",
|
|
" \"labelName\": \"\",\n",
|
|
" \"spec\": \"\",\n",
|
|
" \"applyModel\": \"\",\n",
|
|
" \"sellPurchaseStatuses\": [\n",
|
|
" 2,\n",
|
|
" 3,\n",
|
|
" 4,\n",
|
|
" 5,\n",
|
|
" 1\n",
|
|
" ],\n",
|
|
" \"customInvoiceCategory\": 0,\n",
|
|
" \"getThirdPlatformCode\": 0\n",
|
|
" }\n",
|
|
" #修改值读取\n",
|
|
" res = requests.post(f'https://ids-goods.f6car.cn/f6-ids-goods/part/getExactPartStockInfo', headers=headers,cookies=cookie_dict, json=pastebin_url_json)\n",
|
|
"\n",
|
|
" print(idMember,\"@\",res.json()['data']['records'][0]['partId'])\n",
|
|
" \n",
|
|
" except:\n",
|
|
" print(idMember)"
|
|
],
|
|
"outputs": [],
|
|
"execution_count": null
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"metadata": {},
|
|
"source": [
|
|
"res.json()['data']['records'][0]['partId']"
|
|
],
|
|
"outputs": [],
|
|
"execution_count": null
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"metadata": {},
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"import requests\n",
|
|
"import json\n",
|
|
"import xlrd\n",
|
|
"import time\n",
|
|
"cookies_str = 'f6-ids-goodsSESSIONID=d7c6430c-5581-493b-b7ab-0c605c5dca86; erpLanguage=zh-CN; tmall=false; prodOrg=10545724654284683060; unp=10907434497537082431; _up=-NillNN-qyBEJ--t3vnSknvoOFt2zfaJs8kB2nw6WeBdXvPFpJjQjaZJ9Q3d-WrAAGgt60MgQHajHWBHMKKxj0CuWypi1JgKCFP1EPEk-HbqEvIRq4Ij1QAE_PJRv-ZNHu3M-GTZ15i2EXSsquRSjOgdkF7BOhBurEj94R-494y5PGg.; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2210907434497537082431%22%2C%22first_id%22%3A%221750b4690af1f6-089dd3a4874eb8-3d634f03-1327104-1750b4690b09d0%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22%24device_id%22%3A%221750b4690af1f6-089dd3a4874eb8-3d634f03-1327104-1750b4690b09d0%22%7D'\n",
|
|
"cookies_str = cookies_str.encode('utf-8').decode('latin-1')\n",
|
|
"\n",
|
|
"cookie_dict = {item.split('=')[0]: item.split('=')[1]\n",
|
|
" for item in cookies_str.split('; ')}\n",
|
|
"\n",
|
|
"headers = {\n",
|
|
" 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.40',\n",
|
|
" \"Content-Type\": \"application/json\",\n",
|
|
" 'origin': 'https://yunxiu.f6car.cn'\n",
|
|
"}\n",
|
|
"#读取excel文件\n",
|
|
"data = xlrd.open_workbook(r\"C:\\Users\\admin\\Desktop\\新建XLS 工作表 (3).xls\")\n",
|
|
"\n",
|
|
"table = data.sheet_by_index(0) # 通过索引顺序获取\n",
|
|
"\n",
|
|
"h = table.nrows\n",
|
|
"\n",
|
|
"l = table.ncols\n",
|
|
"\n",
|
|
"print(u\"表数据的行数为%s,列数为%s\"%(h,l))\n",
|
|
"\n",
|
|
"for i in range(1,h):\n",
|
|
" try:\n",
|
|
"\n",
|
|
" time.sleep(1)\n",
|
|
" \n",
|
|
" idMember =table.cell(i, 0).value #材料id\n",
|
|
"\n",
|
|
" idMember1 =table.cell(i, 1).value #修改内容\n",
|
|
"\n",
|
|
" #get材料属性\n",
|
|
" url = 'https://ids-goods.f6car.cn/f6-ids-goods/part/getPartInfo?partId={}&customInvoiceCategory=0&getThirdPlatformCode=0'.format(idMember)\n",
|
|
"\n",
|
|
" res = requests.get(url,cookies=cookie_dict)\n",
|
|
"\n",
|
|
" strele = res.text[19:-21]\n",
|
|
"\n",
|
|
" pastebin_url_json = json.loads(strele)\n",
|
|
"\n",
|
|
" pastebin_url_json['name'] = idMember1#修改内容\n",
|
|
"\n",
|
|
" #修改值读取\n",
|
|
" res = requests.post(f'https://ids-goods.f6car.cn/f6-ids-goods/part/updatePartInfo', headers=headers,cookies=cookie_dict, json=pastebin_url_json)\n",
|
|
" \n",
|
|
" print(idMember,res.text)\n",
|
|
"\n",
|
|
" except:\n",
|
|
" \n",
|
|
" pass"
|
|
],
|
|
"outputs": [],
|
|
"execution_count": null
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"metadata": {},
|
|
"source": [
|
|
"pastebin_url_json"
|
|
],
|
|
"outputs": [],
|
|
"execution_count": null
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "F6processing",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.9.4"
|
|
},
|
|
"orig_nbformat": 4
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|