Ejemplo n.º 1
0
class NovelSpider1(NovelSpiderBase):
    # name = "NovelXinShuBao"
    name = SpiderTypes.getTypeName_XinShuBao()

    def __init__(self):
        super().__init__()

    def getXpathMainInfo(self, response):
        return response.xpath(
            '//div[@class="box_con"]/div[@id="maininfo"]/div[@id="info"]')

    def getStrMainInfo_Name(self, info):
        return info.xpath('./h1/text()').extract()[0]

    def getStrMainInfo_Author(self, info):
        return info.xpath('./p/text()').extract()[0]

    def getXpathList(self, response):
        return response.xpath('//div[@id="btycz"]/div[@id="list"]/ul/li')

    def getStrItem_Link(self, item):
        link = item.xpath('./a/@href').extract()[0]
        return link

    def getStrItem_Idex(self, item):
        return item.xpath('./a/text()').extract()[0]

    def getXpathItem_Main(self, response):
        return response.xpath(
            '//div[@class="content_read"]/div[@class="box_con"]')

    def getStrItem_Title(self, xpath_main):
        return xpath_main.xpath('./div[@class="bookname"]/h1/text()').extract()[0]\
            .strip()\
            .replace('  ','')\
            .replace('\r', '')\
            .replace('\n', '')\
            .replace('\t', '')

    def getStrItem_Content(self, xpath_main):
        return xpath_main.xpath('./div[@id="content"]/text()').extract()
Ejemplo n.º 2
0
 def getScrapyType(self):
     return SpiderTypes.getTypeName_XinShuBao()