美文网首页
2019-06-05 爬取淘宝网的数据

2019-06-05 爬取淘宝网的数据

作者: 年画儿 | 来源:发表于2019-06-05 21:31 被阅读0次
#没完全理解
import requests


def spider(sn, book_list=[]):
    """ 爬取淘宝网的图数数据 """
    url = 'https://s.taobao.com/api?ajax=true&m=customized&sourceId=tb.index&q={0}'.format(sn)
    rest = requests.get(url).json()
    print(rest)
    bk_list = rest["API.CustomizedApi"]["itemlist"]["auctions"]
    print(len(bk_list))

    for bk in bk_list:
        # 标题
        title = bk['raw_title']
        price = bk['view_price']
        link = bk['detail_url']
        store = bk['nick']
        print('{title}: {price}: {link}: {store}'.format(
            title=title,
            price=price,
            link=link,
            store=store
        ))
        book_list.append({
            'title': title,
            'price': price,
            'link': link,
            'store': store
        })

if __name__ == '__main__':
    spider('9787115428028')

相关文章

网友评论

      本文标题:2019-06-05 爬取淘宝网的数据

      本文链接:https://www.haomeiwen.com/subject/azfexctx.html