Example #1
0
 def test_get_urls_from_xml(self):
     s = PlayListCreator('test.xml', 'out.xml', 0, 'Test')
     self.assertEqual(s.get_url_from_xml(), ['http://itc.ua'])
Example #2
0
 def test_get_tags_from_xml(self):
     s = PlayListCreator('test.xml', 'out.xml', 0, 'Test')
     self.assertEqual(s.get_tags_from_xml(), [[u'div', u'class', u'sad']])
Example #3
0
 def test_scrapper(self):
     s = PlayListCreator('test.xml', 'out.xml', 0, 'Test')
     self.assertEqual(s.scrapper('file:///home/alxant/PathonStady/Laba1/testing/test.html'), None)
Example #4
0
def main():
    config_file = open('run.conf', "r")
    param = config_file.readline()
    depth = config_file.readline()
    genre = config_file.readline()

    print 'Gevent mod: ', param, 'Depth: ', depth, 'Genre: ', genre

    scrappy = PlayListCreator(input_path='Start.xml', output_path='out.xml',
                              given_depth=depth, genre=genre)
    urls = scrappy.get_url_from_xml()
    tags = scrappy.get_tags_from_xml()

    if param == 'gevent\n':
        scrappy.multitask_scrapper(urls)
        scrappy.write_xml()
    elif param == 'non-gevent\n':
        for url in urls:
            scrappy.scrapper(url)
        scrappy.write_xml()
    else:
        raise RuntimeError("RuntimeError")