Ejemplo n.º 1
0
    def handle_response(self, flow):
        # we only care about URLs that are going to FFRK_HOST


        if FFRK_HOST in flow.request.host:
            # get_battle_init_data call
            if BATTLE_INFO_PATH in flow.request.path:
                print flow.request.path + " called"
                with decoded(flow.response):
                    json_data = json.loads(flow.response.content)
                    print get_drops_from_json(json_data)

                    if DUMP_CONTENT_TO_FILES:
                        dump_json_to_file(json_data, BATTLE_INFO_FILENAME + get_suffix_with_unix_time())

            # dff/party/list call
            elif EQUIPMENT_LIST_PATH in flow.request.path:
                print flow.request.path + " called"
                with decoded(flow.response):
                    json_data = json.loads(flow.response.content)
                    print get_equipment_id_from_json(json_data)

                    if DUMP_CONTENT_TO_FILES:
                        dump_json_to_file(json_data, EQUIPMENT_LIST_FILENAME + get_suffix_with_unix_time())

            else:
                print flow.request.path + " called; no processing done\n"

        # forward the reply so it gets passed on
        flow.reply()
Ejemplo n.º 2
0
def test_item_id_parser():
    with open("json/party_list-1430322460.json") as data_file:
        result = get_equipment_id_from_json(json.load(data_file))
        assert "Iron Bangle (VII)" in result and "Dark Orb" in result