Commit e28d7f4f by baiquan

add a_bogus

parent d660c663
This source diff could not be displayed because it is too large. You can view the blob instead.
import random import random
import time import time
from urllib.parse import urlencode
import requests import execjs
from curl_cffi import requests, CurlMime
from doudian.login import login from common import get_ms_token
from login import login
headers = { headers = {
'Accept': 'application/json, text/plain, */*', 'Accept': 'application/json, text/plain, */*',
...@@ -80,8 +83,19 @@ def search_category(cookies, key): ...@@ -80,8 +83,19 @@ def search_category(cookies, key):
print(response.text) print(response.text)
return response.json()['data'] return response.json()['data']
def get_a_bogus(a_bogus_js_path, params,data, userAgent):
with open(a_bogus_js_path, 'r', encoding='gbk') as f:
a_bogus_js = f.read()
a_bogus = execjs.compile(a_bogus_js).call('get_ab', params,data, userAgent)
# print(f'a_bogus: {a_bogus}')
return a_bogus
def get_schema(cookies, category_id): def get_schema(cookies, category_id):
params = {
'appid': '1',
'_bid': 'ffa_goods',
'msToken': get_ms_token(160),
}
json_data = { json_data = {
'context': { 'context': {
'feature': {}, 'feature': {},
...@@ -92,9 +106,11 @@ def get_schema(cookies, category_id): ...@@ -92,9 +106,11 @@ def get_schema(cookies, category_id):
'appid': 1, 'appid': 1,
'_bid': 'ffa_goods', '_bid': 'ffa_goods',
} }
url = 'https://fxg.jinritemai.com/product/tproduct/getSchema?appid=1' url = 'https://fxg.jinritemai.com/product/tproduct/getSchema'
response = requests.post(url, cookies=cookies, headers=headers, json=json_data, ) a_bogus = get_a_bogus('a_bogus.js', urlencode(params), json_data, headers['User-Agent'])
# print(response.text) params['a_bogus'] = a_bogus
response = requests.post(url,params=params,cookies=cookies,headers=headers,json=json_data,impersonate="chrome131")
print(response.text)
return response.json()['data'] return response.json()['data']
...@@ -107,13 +123,15 @@ def upload_image(cookies, image_path_list): ...@@ -107,13 +123,15 @@ def upload_image(cookies, image_path_list):
print(response.text) print(response.text)
return response.json()['data'] return response.json()['data']
def upload_image_by_bytes(cookies: dict, image_bytes: list[bytes]):
def upload_image_by_bytes(cookies, image_bytes):
url = 'https://fxg.jinritemai.com/product/img/batchupload?_bid=ffa_goods' url = 'https://fxg.jinritemai.com/product/img/batchupload?_bid=ffa_goods'
files = {} mp = CurlMime()
for i, bytes in enumerate(image_bytes): for i, byte_data in enumerate(image_bytes):
files[f'image[{i}]'] = ('image.jpg', bytes, 'image/jpeg') mp.addpart(name=f"image[{i}]", content_type="image/jpeg",filename=f"image_{i}.jpg", data=byte_data)
response = requests.post(url, cookies=cookies, headers=headers, files=files) response = requests.post(url,cookies=cookies,headers=headers,data={"foo":"bar"},multipart=mp,impersonate="chrome131")
print(response.text) print(response.text)
mp.close()
return response.json()['data'] return response.json()['data']
...@@ -289,10 +307,10 @@ def add_with_schema(cookies, schema, goods_params): ...@@ -289,10 +307,10 @@ def add_with_schema(cookies, schema, goods_params):
], ],
'1687': [ '1687': [
{ {
'value_id': '1879107146', 'value_id': '596120136',
'value_name': 'NARWAL/云鲸', 'value_name': "无品牌",
'tags': { 'tags': {
'brand_cn_name': '云鲸', 'brand_cn_name': '',
}, },
}, },
], ],
...@@ -361,12 +379,12 @@ def add_with_schema(cookies, schema, goods_params): ...@@ -361,12 +379,12 @@ def add_with_schema(cookies, schema, goods_params):
'pic': { # 主图 'pic': { # 主图
'value': pic, 'value': pic,
}, },
# 'main_pic_video': { # 主图视频 'main_pic_video': { # 主图视频
# 'value': [{ 'value': [{
# "resource_id": "v03ecag10000cvscg4vog65n5earpkjg", # video_id "resource_id": "v0decag10000d08sj0fog65tje0hvkf0", # video_id
# "video_choice": 1 "video_choice": 1
# }], }],
# }, },
'pickup_method': { 'pickup_method': {
'value': '0', 'value': '0',
}, },
...@@ -408,6 +426,365 @@ def add_with_schema(cookies, schema, goods_params): ...@@ -408,6 +426,365 @@ def add_with_schema(cookies, schema, goods_params):
'session': {}, 'session': {},
'appid': 1, 'appid': 1,
} }
json_data = {
'schema': {
'model': {
'sku_detail': {
'value': [
{
'id': '06474489c5e9-9de849-f79ed211234e',
'stock_info': {
'stock_num': 0,
},
'sku_status': True,
'confirm_no_barcode': False,
'spec_detail_ids': [
'999702516961383667',
],
'price': '500',
},
],
},
'spec_detail': {
'value': [
{
'id': '993164291474396531',
'is_default': True,
'name': '默认',
'spec_values': [
{
'id': '999702516961383667',
'name': '默认',
},
],
},
],
},
'white_background_pic': {
'value': None,
},
'title': {
'value': '悬挂式抽纸家用实惠装纸巾卫生间挂式厕纸大包学生擦手纸面巾纸',
},
'after_sale': {
'value': {
'quality_problem_return': {
'option_id': None,
'selected': True,
},
'supply_day_return_selector': {
'option_id': '7-1',
'selected': True,
},
'three_guarantees': {
'option_id': '-1',
'selected': True,
},
},
},
'alli_promotion_plan_switch': {
'value': False,
},
'area_stock_switcher': {
'value': False,
},
'category_properties': {
'value': {
'1345': [
{
'value_id': '35497',
'value_name': '白色',
},
],
'1687': [
{
'value_id': '596120136',
'value_name': '无品牌',
'tags': {
'brand_cn_name': '',
},
},
],
'2398': [
{
'value_id': '7310',
'value_name': '否',
},
],
'2426': [
{
'value_id': '23964',
'value_name': '是',
},
],
'2592': [
{
'value_id': '32540',
'value_name': '复古怀旧',
},
],
'3093': [
{
'value_id': '18444',
'value_name': '木',
},
],
'3127': [
{
'value_id': '19165',
'value_name': '棉',
},
],
},
},
'delivery_delay_day': {
'value': '1',
},
'description': {
'value': '<p><img src="https://p3-aio.ecombdimg.com/obj/ecom-shop-material/webp_m_429626f96fb4d3ef69a18917c83ead78_sx_79186_www1080-1080" style="max-width:100%;"/></p>',
},
'freight_id': {
'value': '640336706',
},
'goods_category': {
'value': {
'category_leaf_id': 26152,
'first_cid': 20059,
'first_cname': '住宅家具',
'fourth_cid': 0,
'fourth_cname': '',
'second_cid': 20935,
'second_cname': '几类',
'third_cid': 26152,
'third_cname': '角几/边几',
},
},
'interest_free_activity': {
'value': [],
},
'interest_free_activity_id': {
'value': {
'activity_template_id': 'AT202406281206214183151154',
},
},
'interest_free_open': {
'value': False,
},
'main_image_three_to_four': {
'value': [],
},
'pic': {
'value': [
{
'url': 'https://p3-aio.ecombdimg.com/obj/ecom-shop-material/webp_m_429626f96fb4d3ef69a18917c83ead78_sx_79186_www1080-1080',
},
],
},
'pickup_method': {
'value': '0',
},
'presell_type': {
'value': '0',
},
'product_type': {
'value': '0',
},
'qualification': {
'value': {},
},
'reduce_type': {
'value': '1',
},
'short_product_name': {
'value': '',
},
'start_sale_type': {
'value': '0',
},
'title_prefix': {
'value': '',
},
'title_suffix': {
'value': '',
},
'title_use_brand_name': {
'value': False,
},
'main_pic_video': {
'value': [
{
'resource_id': 'v03ecag10000d08u2t7og65raa9ti9e0',
'video_choice': 1,
},
],
},
'detail_prettify_uri': {
'value': 'detail_prettify_ae94caec6967cb5847d3ea4073684051_1uA1ll',
},
},
'context': {
'ability': [],
'biz_identity': 'xiaodian',
'category_id': '26152',
'feature': {
'not_first_render': '1',
'session_data': '{"stock_incr_mode":false,"only_update_stock":null}',
'min_sku_price': '50000',
},
'gray_components': [
'mass_auction_rules',
'restricted_purchasing_plan',
'deposit_is_select',
'deposit_price',
'deposit_find_time',
'category_property_pic',
'product_desc_text',
'category_properties',
'is_evaluate_opened',
'weight_unit',
'weight_value',
'pic',
'qualification',
'poi_code_type',
'poi_coupon_return_methods',
'poi_total_can_use_count',
'poi_condition',
'poi_link',
'poi_valid_range',
'poi_service_num',
'poi_notification',
'poi_lib_id',
'poi_financial_settlement_rate',
'poi_ids',
'poi_valid_type',
'poi_valid_days',
'after_sale',
'supply_day_return_selector',
'damaged_order_return',
'support_authentic_guaranteeV2',
'support_allergy_returnV2',
'supply_allergy_return',
'quality_problem_return',
'supply_red_ass_return',
'worry_free_settlement',
'is_large_product',
'three_guarantees',
'fix_duration',
'extended_duration',
'dcar_coupon_type',
'presell_type',
'delivery_delay_day',
'appoint_delivery_switch',
'appoint_delivery_day',
'delay_rule_switch',
'delay_rule_order_time',
'delay_rule_delivery_day',
'delay_rule_delivery_date',
'presell_end_time_switch',
'presell_end_time',
'presell_delivery_type',
'presell_delay',
'presell_time',
'promotion_goods_coupon_comp',
'product_instant_discount_coupon',
'product_promotion',
'size_info_template_id',
'default_process_time',
'quality_control',
'product_ingredients',
'spec_detail',
'use_old_spec',
'customs_clear_type',
'cdf_category',
'cross_warehouse_id',
'origin_country_id',
'source_country_id',
'brand_country_id',
'tax_payer',
'net_weight_qty',
'gx_freight_id',
'nutritional_information',
'car_vin_code',
'item_max_per_order',
'#notification',
'sku_detail',
'area_stock_switcher',
'is_hainan_post',
'is_hainan_pick',
'refund_tips',
'main_image_three_to_four',
'short_product_name',
'dcar_coupon_rights',
'reference_price',
'reference_price_certificate_type',
'reference_price_certificate_urls',
'freight_id',
'cp_contract_info',
'contract_interest_subsidy_switch',
'custom_property',
'product_type',
'sale_channel_type',
'account_template_id',
'title',
'title_prefix',
'title_suffix',
'title_use_brand_name',
'title_struct',
'title_switcher',
'search_strategy_2c',
'start_sale_type',
'enable_all_channel_product_online',
'shop_category',
'white_background_pic',
'quality_inspection_info',
'market_price',
'use_gold_price',
'gold_price_type',
'description',
'detail_prettify_uri',
'detail_prettify_info',
'pickup_method',
'common_reject',
'outer_product_id',
'privilege_service',
'interest_free_open',
'interest_free_activity_id',
'interest_free_activity',
'reduce_type',
'long_pic',
'main_pic_video',
'auction_type',
'goods_category',
'total_buy_num',
'max_buy_num',
'min_buy_num',
'is_auto_charge',
'is_c2b_switch_on',
'micro_app_id',
'inner_shop_category',
'category_property_prefill',
'category_property_prefill_spu',
'category_property_prefill_barcode',
'edu_discount',
'return_address',
'alli_promotion_plan_switch',
],
'model_type': '',
'operation_type': 'normal',
'product_id': '0',
'token': '20250430145726529511E2BB862F829271',
'version': 'v1_v8_v9',
},
},
'pass_through_extra': {},
'_nsToken': 'VFZSV3mVVNXFaM2RPUkdjeFRWUmpNRTVVYXpWT2VtTjZUa1JKTVU1QlBUMD0=',
'check_status': 2,
'session': {},
'appid': 1,
'__token': 'a0c08252cbd0da56d0b78a276ef9b594',
'_bid': 'ffa_goods',
'_lid': '977342588334',
}
if goods_params.get('three_guarantees') == '2' and goods_params.get('extended_duration'): if goods_params.get('three_guarantees') == '2' and goods_params.get('extended_duration'):
json_data['schema']['model']['extended_duration'] = { # 选择售后有效期 json_data['schema']['model']['extended_duration'] = { # 选择售后有效期
'option_id': goods_params.get('extended_duration', '30'), # 30 30天 60 60天 90 90天 120 120天 180 180天 365 1年 'option_id': goods_params.get('extended_duration', '30'), # 30 30天 60 60天 90 90天 120 120天 180 180天 365 1年
...@@ -425,8 +802,8 @@ if __name__ == '__main__': ...@@ -425,8 +802,8 @@ if __name__ == '__main__':
password = 'Cc123123' password = 'Cc123123'
# cookies = login(account, password, headers) # cookies = login(account, password, headers)
cookies = { cookies = {
'PHPSESSID': '06c1a5eb0db6263a5cb2d8cd7fcdcd1f', 'PHPSESSID': '232b5651dcd01b596b830d540362643d',
'PHPSESSID_SS': '06c1a5eb0db6263a5cb2d8cd7fcdcd1f', 'PHPSESSID_SS': '232b5651dcd01b596b830d540362643d',
} }
...@@ -486,6 +863,6 @@ if __name__ == '__main__': ...@@ -486,6 +863,6 @@ if __name__ == '__main__':
# category_id = search_category(cookies, key)[0]['id'] # category_id = search_category(cookies, key)[0]['id']
category_id = search_category(cookies, key)[0]['id'] category_id = search_category(cookies, key)[0]['id']
get_spec_detail_options(cookies, category_id) get_spec_detail_options(cookies, category_id)
search_brand_prefix(cookies, category_id, 'Redmi') search_brand_prefix(cookies, category_id, '云鲸')
# schema = get_schema(cookies, category_id) schema = get_schema(cookies, category_id)
# add_with_schema(cookies, schema, goods_params) # add_with_schema(cookies, schema, goods_params)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment