()
提取商品数据
提取商品数据
提取商品数据
def get_products():
    """
    提取商品数据
    """
    html = browser.page_source
    doc = pq(html)
    items = doc('#mainsrp-itemlist .items .item').items()
    for item in items:
        product = {
            'image': item.find('.pic .img').attr('data-src'),
            'price': item.find('.price').text(),
            'deal': item.find('.deal-cnt').text(),
            'title': item.find('.title').text(),
            'shop': item.find('.shop').text(),
            'location': item.find('.location').text()
        }
        print(product)
        save_to_mongo(product)
def get_products ( ) : html = browser . page_source doc = pq ( html ) items = doc ( '#mainsrp-itemlist .items .item' ) . items ( ) for item in items : product = { 'image' : item . find ( '.pic .img' ) . attr ( 'data-src' ) , 'price' : item . find ( '.price' ) . text ( ) , 'deal' : item . find ( '.deal-cnt' ) . text ( ) , 'title' : item . find ( '.title' ) . text ( ) , 'shop' : item . find ( '.shop' ) . text ( ) , 'location' : item . find ( '.location' ) . text ( ) } print ( product ) save_to_mongo ( product )