python爬虫scrapy框架灵巧使用

(1)下面代码意义在于可以执行main.py文件运行程序,当然我们也可以在shell中运行scrapy crawl name

from scrapy import cmdline
cmdline.execute("scrapy crawl name".split())

(2)在文件头添加from scrapy import Field,后面的Field前就不用再添加scrapy,目的是为了提高效率

from scrapy import Item, Field

class DoubanmovieItem(Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    title = Field()
    movieInfo = Field()
    star = Field()
    quote = Field()


你可能感兴趣的:(python爬虫scrapy框架灵巧使用)