目标网址——https://list.tmall.com/search_product.htmspm=a220m.1000858.1000724.4.JnyabL&cat=50025135&sort=d&style=g&from=mallfp..pc_1_searchbutton&tmhkmain=0#J_Filter,界面如下,我们要抓取这个界面的商品价格、名称、和商品的链接
打开商品连接后,我们要获取的信息为店铺名称和链接,如下图所示:
项目结构如图:
贴代码:
tm_goods.py
# -*- coding: utf-8 -*- import scrapy from topgoods.items import TopgoodsItem import sys reload(sys) sys.setdefaultencoding('utf-8') class TmGoodsSpider(scrapy.Spider): name = "tm_goods" allowed_domains =["http://www.tmall.com"] start_urls = ("http://list.tmall.com/search_product.htm?spm=a220m.1000858.1000724.4.Jn