python脚本结合计算引擎快速获取亚马逊的父ASIN并保存到数据库
按照亚马逊的规则,一个ASIN只能有一个父ASIN,在某些情况下不得分析asin的所属变体父asin是否同一个。
Python代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import op_data_web_hook as webhook table_id_dp = "xxxx" def get_parent_asin_by_page_source(res): if res is None : return "" try : res = str (res) parent_value = "" if res.__contains__( "parentAsin=" ): parent_value = res.split( "parentAsin=" )[ 1 ].split( "&" )[ 0 ] elif res.__contains__( ',"parentAsin":"' ): parent_value = res.split( ',"parentAsin":"' )[ 1 ].split( '",' )[ 0 ] if parent_value is None or parent_value = = "": return "" return parent_value except : return "" def auto_get_and_save_parent_asin_by_page_source_and_asin(res, asin): parent_asin = get_parent_asin_by_page_source(res) if parent_asin ! = "": sql = "update table_id set update_time=now(),parent_asin='" + str (parent_asin) + "' where asin='" + str (asin) + "'" print ( "-- auto_get_and_save_parent_asin_by_page_source_and_asin --" ) print (sql) webhook.modify_by_sql_and_table_id(sql, table_id_dp) return 1 return 0 |
done
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步