示例#1
0
    def test_mustache(self):
        o = 'tests/temp_data/mustache'
        c = localcrawl.Crawler('tests/data/mustache/index.html', o).crawl()
        self.assertEqual(1, c)

        contents = self.all_contents(o)
        self.assertIn('Fork: <b>$1.19</b>', contents)
示例#2
0
 def test_utf8(self):
     o = 'tests/temp_data/simple_site'
     c = localcrawl.Crawler('tests/data/simple_site/index.html',
                            o,
                            output_encoding='utf8').crawl()
     self.assertEqual(1, c)
     self.assertIn('<title>Simple Site</title>', self.all_contents(o))
示例#3
0
    def test_link(self):
        o = 'tests/temp_data/linked_page'
        c = localcrawl.Crawler('tests/data/linked_page/index.html', o).crawl()
        self.assertEqual(2, c)

        contents = self.all_contents(o)
        self.assertIn('<title>Linked Page</title>', contents)
        self.assertIn('<title>Linked Page, Page 2</title>', contents)
示例#4
0
 def test_flat_output(self):
     o = 'tests/temp_data/flat_output'
     c = localcrawl.Crawler('tests/data/loop_sub/index.html',
                            o,
                            flat_output=True).crawl()
     self.assertEqual(2, c)
示例#5
0
 def test_nested(self):
     o = 'tests/temp_data/nested'
     c = localcrawl.Crawler('tests/data/nested/index.html', o).crawl()
     self.assertEqual(2, c)
示例#6
0
 def test_loop_sub(self):
     o = 'tests/temp_data/loop_sub'
     c = localcrawl.Crawler('tests/data/loop_sub/index.html', o).crawl()
     self.assertEqual(2, c)
示例#7
0
 def test_links(self):
     o = 'tests/temp_data/links'
     c = localcrawl.Crawler('tests/data/links/index.html', o).crawl()
     self.assertEqual(1, c)
示例#8
0
 def test_ascii(self):
     o = 'tests/temp_data/simple_site'
     with self.assertRaises(UnicodeEncodeError):
         localcrawl.Crawler('tests/data/simple_site/index.html',
                            o,
                            output_encoding='ascii').crawl()