from information_summary_filter.jd import get_goods_id,get_detailInfo

def init(url,keyword):
    goods_ids, prices = get_goods_id(url)
    for goods_id,price in zip(goods_ids,prices):
        get_detailInfo(goods_id,price,keyword)


if __name__ =='__main__':
    # 手机，耳机，电脑
    # keywords = input('请输入要爬取的商品（，分开）：')
    keywords = '手机，耳机，电脑'
    keywords = keywords.split('，')
    totalPage = 10 #设置爬取页数
    for keyword in keywords:
        for page in range(1,int(totalPage)*2,2):
            url = 'https://search.jd.com/Search?keyword={}&enc=utf-8&qrst=1&rt=1&stop=1&vt=2&wq=%E5%BA%8A&page={}&click=0'.format(keyword,page)
            init(url,keyword)
