Skip to content

Support multiple JSON fragments in HTML+XPath+JSON mode#7369

Merged
Alkarex merged 3 commits intoFreshRSS:edgefrom
Alkarex:support-json-multiple-fragments
Mar 24, 2025
Merged

Support multiple JSON fragments in HTML+XPath+JSON mode#7369
Alkarex merged 3 commits intoFreshRSS:edgefrom
Alkarex:support-json-multiple-fragments

Conversation

@Alkarex
Copy link
Member

@Alkarex Alkarex commented Feb 24, 2025

fix #7352 (reply in thread)
E.g. HTML with one <script type="application/ld+json">...</script> per item.
Example: https://san-diego.events/venue/the-rady-shell-at-jacobs-park-events/

fix FreshRSS#7352 (reply in thread)
E.g. HTML with one `<script type="application/ld+json">...</script>` per item.
@Alkarex Alkarex added this to the 1.27.0 milestone Feb 24, 2025
@Alkarex
Copy link
Member Author

Alkarex commented Feb 24, 2025

<?xml version="1.0" encoding="UTF-8"?>
<opml xmlns:frss="https://freshrss.org/opml" version="2.0">
	<head>
		<title>FreshRSS</title>
		<dateCreated>Mon, 24 Feb 2025 22:33:10 +0100</dateCreated>
	</head>
	<body>
		<outline
			text="the-rady-shell-at-jacobs-park-events"
			type="HTML+XPath+JSON+DotNotation"
			xmlUrl="https://san-diego.events/venue/the-rady-shell-at-jacobs-park-events/"
			htmlUrl="https://san-diego.events/venue/the-rady-shell-at-jacobs-park-events/"
			description="RSS feed of san-diego.events/venue/the-rady-shell-at-jacobs-park-events/"
			frss:jsonItem="$"
			frss:jsonItemTitle="name"
			frss:jsonItemContent="description"
			frss:jsonItemUri="offers[0].url"
			frss:jsonItemAuthor="performer.name"
			frss:jsonItemTimestamp="startDate"
			frss:jsonItemThumbnail="image"
			frss:xPathToJson="//body//script[@type=&quot;application/ld+json&quot;]"
		/>
	</body>
</opml>

image

@Alkarex
Copy link
Member Author

Alkarex commented Feb 24, 2025

Ping @dahlbergc

@Frenzie
Copy link
Member

Frenzie commented Feb 25, 2025

What an odd page. 🤨

$xpath = new DOMXPath($doc);
$json = @$xpath->evaluate('normalize-space(' . $xPathToJson . ')');
return is_string($json) ? $json : null;
$jsons = @$xpath->evaluate($xPathToJson);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like JSON fragments might potentially sound better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Alkarex Alkarex modified the milestones: 1.27.0, 1.26.1 Mar 5, 2025
@Alkarex Alkarex merged commit 9114b9a into FreshRSS:edge Mar 24, 2025
1 check passed
@Alkarex Alkarex deleted the support-json-multiple-fragments branch March 24, 2025 13:08
@Alkarex Alkarex modified the milestones: 1.27.0, 1.26.2 Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants