def scrapeConversation(self, merge, offset, timestampOffset, chunkSize, limit, isGroupConversation):
    'Retrieves conversation messages and stores them in a JSON file\n        If merge is specified, the new messages will be merged with the previous version of the conversation, if present\n        '
    if merge:
        if (not os.path.exists(os.path.join(self._directory, 'conversation.json'))):
            logger.error('Conversation not present. Merge operation not possible')
            return
        with open(os.path.join(self._directory, 'conversation.json')) as conv:
            convMessages = json.load(conv)
            numMergedMsgs = 0
    if (not os.path.exists(self._directory)):
        os.makedirs(self._directory)
    logger.info('Starting scraping of conversation {}'.format(self._convID))
    messages = []
    msgsData = ''
    timestamp = ('' if (timestampOffset == 0) else str(timestampOffset))
    while (self.CONVERSATION_ENDMARK not in msgsData):
        requestChunkSize = (chunkSize if (limit <= 0) else min(chunkSize, (limit - len(messages))))
        reqData = self.generateRequestData(offset, timestamp, requestChunkSize, isGroupConversation)
        logger.info('Retrieving messages {}-{}'.format(offset, (requestChunkSize + offset)))
        msgsData = self.executeRequest(reqData)
        jsonData = json.loads(msgsData)
        if (jsonData and ('payload' in jsonData) and jsonData['payload']):
            if (('actions' in jsonData['payload']) and jsonData['payload']['actions']):
                actions = jsonData['payload']['actions']
                if (merge and (convMessages[(- 1)]['timestamp'] > actions[0]['timestamp'])):
                    for (i, action) in enumerate(actions):
                        if (convMessages[(- 1)]['timestamp'] == actions[i]['timestamp']):
                            numMergedMsgs = (len(actions[(i + 1):(- 1)]) + len(messages))
                            messages = ((convMessages + actions[(i + 1):(- 1)]) + messages)
                            break
                    break
                if (len(messages) == 0):
                    messages = actions
                else:
                    messages = (actions[:(- 1)] + messages)
                timestamp = str(actions[0]['timestamp'])
            else:
                if ('errorSummary' in jsonData):
                    logger.error(('Response error: ' + jsonData['errorSummary']))
                else:
                    logger.error('Response error. No messages found')
                    logger.error(msgsData)
                return
        else:
            logger.error('Response error. Empty data or payload')
            logger.error(msgsData)
            logger.info('Retrying in {} seconds'.format(self.ERROR_WAIT))
            time.sleep(self.ERROR_WAIT)
            continue
        offset += chunkSize
        if ((limit != 0) and (len(messages) >= limit)):
            break
        time.sleep(self.REQUEST_WAIT)
    if merge:
        logger.info('Successfully merged {} new messages'.format(numMergedMsgs))
        logger.info('Conversation total message count = {}'.format(len(messages)))
    else:
        logger.info('Conversation scraped successfully. {} messages retrieved'.format(len(messages)))
    self.writeMessages(messages)
Retrieves conversation messages and stores them in a JSON file
If merge is specified, the new messages will be merged with the previous version of the conversation, if present
def scrapeConversation(self, merge, offset, timestampOffset, chunkSize, limit, isGroupConversation):
    'Retrieves conversation messages and stores them in a JSON file\n        If merge is specified, the new messages will be merged with the previous version of the conversation, if present\n        '
    if merge:
        if (not os.path.exists(os.path.join(self._directory, 'conversation.json'))):
            logger.error('Conversation not present. Merge operation not possible')
            return
        with open(os.path.join(self._directory, 'conversation.json')) as conv:
            convMessages = json.load(conv)
            numMergedMsgs = 0
    if (not os.path.exists(self._directory)):
        os.makedirs(self._directory)
    logger.info('Starting scraping of conversation {}'.format(self._convID))
    messages = []
    msgsData = 
    timestamp = ( if (timestampOffset == 0) else str(timestampOffset))
    while (self.CONVERSATION_ENDMARK not in msgsData):
        requestChunkSize = (chunkSize if (limit <= 0) else min(chunkSize, (limit - len(messages))))
        reqData = self.generateRequestData(offset, timestamp, requestChunkSize, isGroupConversation)
        logger.info('Retrieving messages {}-{}'.format(offset, (requestChunkSize + offset)))
        msgsData = self.executeRequest(reqData)
        jsonData = json.loads(msgsData)
        if (jsonData and ('payload' in jsonData) and jsonData['payload']):
            if (('actions' in jsonData['payload']) and jsonData['payload']['actions']):
                actions = jsonData['payload']['actions']
                if (merge and (convMessages[(- 1)]['timestamp'] > actions[0]['timestamp'])):
                    for (i, action) in enumerate(actions):
                        if (convMessages[(- 1)]['timestamp'] == actions[i]['timestamp']):
                            numMergedMsgs = (len(actions[(i + 1):(- 1)]) + len(messages))
                            messages = ((convMessages + actions[(i + 1):(- 1)]) + messages)
                            break
                    break
                if (len(messages) == 0):
                    messages = actions
                else:
                    messages = (actions[:(- 1)] + messages)
                timestamp = str(actions[0]['timestamp'])
            else:
                if ('errorSummary' in jsonData):
                    logger.error(('Response error: ' + jsonData['errorSummary']))
                else:
                    logger.error('Response error. No messages found')
                    logger.error(msgsData)
                return
        else:
            logger.error('Response error. Empty data or payload')
            logger.error(msgsData)
            logger.info('Retrying in {} seconds'.format(self.ERROR_WAIT))
            time.sleep(self.ERROR_WAIT)
            continue
        offset += chunkSize
        if ((limit != 0) and (len(messages) >= limit)):
            break
        time.sleep(self.REQUEST_WAIT)
    if merge:
        logger.info('Successfully merged {} new messages'.format(numMergedMsgs))
        logger.info('Conversation total message count = {}'.format(len(messages)))
    else:
        logger.info('Conversation scraped successfully. {} messages retrieved'.format(len(messages)))
    self.writeMessages(messages)