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'])
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']])
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)
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")