def scrape(page_id, tstamp, useKafka, useES): access_token = get_access('app.txt') pageStamp = get_tstamp(page_id, tstamp, "save_times") save_shelve(page_id, 'save_times') scraper = FB_SCRAPE(useKafka, useES, False, False) scraper.scrapeFacebookPageFeedStatus2(page_id, access_token, pageStamp) if os.environ.get("COMMENTS") is not None: scraper.scrapeComments()
def test_getFacebookPageFeedData(self): access = os.environ['FB_ID'] + "|" + os.environ['FB_KEY'] a = FB_SCRAPE(False, False, False, False) data = a.getFacebookPageFeedData("paddlesoft", access, 100, 0) if ("message" in data["data"][0]): good = 1 else: good = 2 self.assertEqual(good, 1)
def test_procesFacebookPageFeedStatus(self): a2 = FB_SCRAPE(False, False, False, False) a = { 'message': 'I may have the opportunity to get a wavehopper. the specs say 210 lbs max but it is a really big boat. has anyone here tried putting more weight than that in it?', 'from': { 'id': '55', 'name': 'somename' }, 'comments': { 'summary': { 'can_comment': False, 'total_count': 1, 'order': 'chronological' }, 'data': [] }, 'reactions': { 'summary': { 'total_count': 0, 'viewer_reaction': 'NONE' }, 'data': [] }, 'created_time': '2017-02-03T13:55:35+0000', 'type': 'status', 'id': '115285708497149_1769803846378652' } access = os.environ['FB_ID'] + "|" + os.environ['FB_KEY'] self.assertEqual(a2.processFacebookPageFeedStatus(a, access), ( '115285708497149_1769803846378652', 'I may have the opportunity to get a wavehopper. the specs say 210 lbs max but it is a really big boat. has anyone here tried putting more weight than that in it?', '', 'status', '', '2017-02-03 08:55:35', 0, 1, 0, 0, 0, 0, 0, 0, 0, '55', ))
def test_getReactionsForStatus(self): a = FB_SCRAPE(False, False, False, False) access = os.environ['FB_ID'] + "|" + os.environ['FB_KEY'] status_id = "115285708497149_1700908723268165" print(a.getReactionsForStatus(status_id, access)) self.assertEquals( a.getReactionsForStatus(status_id, access), { 'angry': { 'data': [], 'summary': { 'total_count': 0 } }, 'haha': { 'data': [], 'summary': { 'total_count': 0 } }, 'id': '115285708497149_1700908723268165', 'like': { 'data': [], 'summary': { 'total_count': 7 } }, 'love': { 'data': [], 'summary': { 'total_count': 0 } }, 'sad': { 'data': [], 'summary': { 'total_count': 0 } }, 'wow': { 'data': [], 'summary': { 'total_count': 1 } } })
def test_reaction_id(self): scraper = FB_SCRAPE(False, False, False, False) status_id = "457628327745071_746174208890480" access_token = "354322838020934|" + os.environ['FB_KEY'] self.assertEqual( scraper.get_reaction_ids(status_id, access_token), { "paging": { "cursors": { "after": "TlRneU1qTXdORG94TkRnM05qUTBOell3T2pJMU5EQTVOakUyTVRNPQZDZD", "before": "TlRneU1qTXdORG94TkRnM05qUTBOell3T2pJMU5EQTVOakUyTVRNPQZDZD" } }, "data": [{ "id": "10103915113063889", "type": "LIKE" }] })