码迷,mamicode.com
首页 > 其他好文 > 详细

scrapy

时间:2019-10-30 16:29:44      阅读:58      评论:0      收藏:0      [点我收藏+]

标签:encoding   code   div   auth   utf-8   fir   color   mini   coding   

__author__ = Administrator
# -*- encoding:utf-8 -*-
import scrapy
class QuoteSpider(scrapy.Spider):
    name = poxiao
    start_urls=[https://www.poxiao.com/type/movie/]
    def parse(self, response):#固定的
        quotes=response.xpath(//li/h3)#内容
        for quote in quotes:
            yield {
                name:quote.xpath(./a/text()).extract_first(),
                author:https://www.poxiao.com+quote.xpath(./a/@href).extract_first()
            }
            next_page=response.xpath(//div[@class="list-pager"]/a[last()-1]/@href).extract_first()
            if next_page:
                yield response.follow(next_page,self.parse)

用SCRAPY爬取某网页链接地址

scrapy runspider ***.py  运行此工程

SCRAPY runspider ***.py -o aa.json      保存成JSON文件

scrap runspider ***.py -o aa.csv -t csv    保存成EXCEL

scrapy

标签:encoding   code   div   auth   utf-8   fir   color   mini   coding   

原文地址:https://www.cnblogs.com/xupanfeng/p/11765545.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!