def Gatherer(pk): print 'Proccessing %s' % pk name = name_func(pk) if name != False: print name #LogData(1,**{'pk': pk}) Wikimedia = WikiMediaScraper(name) results = {} if Wikimedia.get_finall_data(): overwiev = Wikimedia.get_finall_data() #LogData(2,**{'pk':pk_reader(),'name':name, 'URL':Wikimedia.object_endpoint()}).save() results["overview"] = overwiev print 'Connected to %s' % Wikimedia.object_endpoint() else: print 'No wikimedia data' else: print '%s got no name' % pk
def testWikiAPI(self): testtext = "NGC 1 is a spiral galaxy SbbPa Ring located 190 million light-years away in the constellation Pegasus. At about 90,000 light-years in diameter, it is just a little smaller than our galaxy, the Milky Way. It is the first object listed in the New General Catalogue. In the coordinates used at the time of the catalog's compilation (epoch 1860), this object had the lowest right ascension of all the objects in the catalog, making it the first object to be listed when the objects were arranged by right ascension. Since then, the coordinates have shifted, and this object no longer has the lowest right ascension of all the NGC objects." name = 'NGC 1' S = WikiMediaScraper(name) self.assertEqual(S.title, 'NGC 1') self.assertEqual(S.object_endpoint(), 'https://en.wikipedia.org/w/api.php?redirects=&format=json&exintro=&prop=extracts&titles=NGC+1&action=query&explaintext=') self.assertEqual(S.get_finall_data(),testtext) self.assertFalse(WikiMediaScraper('NGC 1111111').get_finall_data())