示例#1
0
 def parseCat(self, response):
     parser = HtmlParser(response)
     if 'Next' not in parser.xpath('//li/a/text()'):
         for i in parser.xpath('//span[@class="bqQuoteLink"]/a//text()'):
             self.mydb.quotes.insert({'quote': i})
     else:
         for i in parser.xpath('//span[@class="bqQuoteLink"]/a//text()'):
             self.mydb.quotes.insert({'quote': i})
         for url in parser.extract_urls('//li/a[contains(text(),"Next")]'):
             yield Request(url, callback="parseCat")
示例#2
0
 def parseCat(self, response):
     parser = HtmlParser(response)
     if 'Next' not in parser.xpath('//li/a/text()'):
         for i in parser.xpath('//span[@class="bqQuoteLink"]/a//text()'):
             self.mydb.quotes.insert({'quote':i})
     else:
         for i in parser.xpath('//span[@class="bqQuoteLink"]/a//text()'):
             self.mydb.quotes.insert({'quote':i})
         for url in parser.extract_urls('//li/a[contains(text(),"Next")]'):
             yield Request(url,callback="parseCat")
示例#3
0
文件: main.py 项目: a1156/Quotebot
 def parseCat(self, response):
     parser = HtmlParser(response)
     dbname= response.meta['u']
     if not  parser.xpath('//a[@class="next_page"]'):
         for i in parser.xpath('//div[@class="quoteText"]'):
             quote = i.text
             for j in i.iterfind('a'):
                 author=j.text
             self.mydb[dbname].insert({'quote':quote,'author':author})
     else:
         for i in parser.xpath('//div[@class="quoteText"]'):
             quote = i.text
             for j in i.iterfind('a'):
                 author=j.text
             self.mydb[dbname].insert({'quote':quote,'author':author})
         
         for url in parser.extract_urls('//a[@class="next_page"]'):
             yield Request(url,callback="parseCat",meta={'u':dbname})
示例#4
0
    def parseCat(self, response):
        parser = HtmlParser(response)
        dbname = response.meta['u']
        if not parser.xpath('//a[@class="next_page"]'):
            for i in parser.xpath('//div[@class="quoteText"]'):
                quote = i.text
                for j in i.iterfind('a'):
                    author = j.text
                self.mydb[dbname].insert({'quote': quote, 'author': author})
        else:
            for i in parser.xpath('//div[@class="quoteText"]'):
                quote = i.text
                for j in i.iterfind('a'):
                    author = j.text
                self.mydb[dbname].insert({'quote': quote, 'author': author})

            for url in parser.extract_urls('//a[@class="next_page"]'):
                yield Request(url, callback="parseCat", meta={'u': dbname})
示例#5
0
 def parseAnimal(self, response):
     print "parseAniml"
     html = HtmlParser(response)
     print "Downloading........"
     for url in html.xpath('//div[@class="primary_photo"]/a/img/@src'):
         urlretrieve(url, url.split("/")[-1])
示例#6
0
    def parseAnimal(self,response):
        print 'parseAniml'
        html = HtmlParser(response)
        print 'Downloading........'
        for url in html.xpath('//div[@class="primary_photo"]/a/img/@src'):
	    urlretrieve(url,url.split('/')[-1])