10桁英数のチェックが必要ないならこれでいけるんじゃね
([i[:10] for i in url.split("/dp/") + url.split("pd_rd_i=") if not i.startswith("https:")] + [""])[0]
チェック必要なら1行ではきびしいか