()
return risk_control
获取订单结算页面信息

    该方法会返回订单结算页面的详细信息：商品名称、价格、数量、库存状态等。

    :return: 结算信息 dict
获取订单结算页面信息
获取订单结算页面信息
def get_checkout_page_detail():
    """获取订单结算页面信息

    该方法会返回订单结算页面的详细信息：商品名称、价格、数量、库存状态等。

    :return: 结算信息 dict
    """
    url = 'http://trade.jd.com/shopping/order/getOrderInfo.action'
    # url = 'https://cart.jd.com/gotoOrder.action'
    payload = {
        'rid': str(int(time.time() * 1000)),
    }
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/531.36",
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
        "Referer": "https://cart.jd.com/cart.action",
        "Connection": "keep-alive",
        'Host': 'trade.jd.com',
    }
    try:
        resp = session.get(url=url, params=payload, headers=headers)
        if not response_status(resp):
            logger.error('获取订单结算页信息失败')
            return ''

        soup = BeautifulSoup(resp.text, "html.parser")
        risk_control = get_tag_value(soup.select('input#riskControl'), 'value')

        order_detail = {
            'address': soup.find('span', id='sendAddr').text[5:],  # remove '寄送至： ' from the begin
            'receiver': soup.find('span', id='sendMobile').text[4:],  # remove '收件人:' from the begin
            'total_price': soup.find('span', id='sumPayPriceId').text[1:],  # remove '￥' from the begin
            'items': []
        }

        logger.info("下单信息：%s", order_detail)
        return order_detail
    except requests.exceptions.RequestException as e:
        logger.error('订单结算页面获取异常：%s' % e)
    except Exception as e:
        logger.error('下单页面数据解析异常：%s', e)
    return risk_control
def get_checkout_page_detail ( ) : url = 'http://trade.jd.com/shopping/order/getOrderInfo.action' # url = 'https://cart.jd.com/gotoOrder.action' payload = { 'rid' : str ( int ( time . time ( ) * 1000 ) ) , } headers = { "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/531.36" , "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3" , "Referer" : "https://cart.jd.com/cart.action" , "Connection" : "keep-alive" , 'Host' : 'trade.jd.com' , } try : resp = session . get ( url = url , params = payload , headers = headers ) if not response_status ( resp ) : logger . error ( '获取订单结算页信息失败') return '' soup = BeautifulSoup ( resp . text , "html.parser" ) risk_control = get_tag_value ( soup . select ( 'input#riskControl' ) , 'value' ) order_detail = { 'address' : soup . find ( 'span' , id = 'sendAddr' ) . text [ 5 : ] , # remove '寄送至： ' from the begin 'receiver' : soup . find ( 'span' , id = 'sendMobile' ) . text [ 4 : ] , # remove '收件人:' from the begin 'total_price' : soup . find ( 'span' , id = 'sumPayPriceId' ) . text [ 1 : ] , # remove '￥' from the begin 'items' : [ ] } logger . info ( "下单信息：%s", order_de t il) return order_detail except requests . exceptions . RequestException as e : logger . error ( '订单结算页面获取异常：%s' % e) except Exception as e : logger . error ( '下单页面数据解析异常：%s', e) return risk_control