Skip to content

Commit

Permalink
Merge pull request #13 from maastrichtlawtech/echr_extractor_issues
Browse files Browse the repository at this point in the history
Echr extractor issues - link_to_query() function
  • Loading branch information
shashankmc authored Aug 7, 2024
2 parents 1bf48c5 + 503d02f commit d705825
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion echr/echr_extractor/ECHR_metadata_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,25 @@ def advanced_function(term, values):
"languageisocode": basic_function

}

start = link.index("{")
link_dictionary = eval(link[start:])
end = link.rindex("}")
json_str = link[start:end+1].replace("'", '"')

try:
link_dictionary = json.loads(json_str)
except json.JSONDecodeError:

print(f"Failed to parse JSON: {json_str}")
link_dictionary = {}
pairs = json_str.strip('{}').split(',')
for pair in pairs:
key, value = pair.split(':', 1)
key = key.strip().strip('"')
value = value.strip().strip('[]').split(',')
link_dictionary[key] = [v.strip().strip('"') for v in value]


base_query = 'https://hudoc.echr.coe.int/app/query/results?query=contentsitename:ECHR' \
' AND (NOT (doctype=PR OR doctype=HFCOMOLD OR doctype=HECOMOLD)) AND ' \
'inPutter&select={select}&sort=itemid%20Ascending&start={start}&length={length}'
Expand Down

0 comments on commit d705825

Please sign in to comment.