I am trying to parse this javascript element using BS4. I want to get that input array into a usable format.
<script type="text/javascript">
require.config.params['matchheader'] = {
input: [162,13,'Crystal Palace','Arsenal','05/08/2022 20:00:00','05/08/2022 00:00:00',6,'FT','0 : 1','0 : 2',,,'0 : 2','England','England']
,
matchId: 1640674
};
</script>
To get the text inside the global variable, I used the following regex:
re.search("input: \[.*?\]", script_element.string).group(0)
which returns:
"input: [162,13,'Crystal Palace','Arsenal','05/08/2022 20:00:00','05/08/2022 00:00:00',6,'FT','0 : 1','0 : 2',,,'0 : 2','England','England']"
I am having some trouble parsing this array because of the empty elements (literal_eval does not work).
Any idea on how to accomplish this? Is there an easier way to do it?
Regards