Bonjour, bonjour…
Sur mon site perso, je collecte quelques flux RSS/Atom, grâce à la function ‘simple_load_xml’ de PHP, et entres autres le flux RSS de mon compte github.
Hors, je me rend compte que les urls renseignées dans l’attribut href sont de type relatif, et non absolu… il manque tout simplement le scheme et le nom de domaine de github avant… (tel que : https://github.com)
Le contenu est celui de $item->content, et peut être de cet acabit :
<div class="issues_comment"><div class="body">
<!-- issue_comment -->
<div class="d-flex border-bottom border-gray-light py-3">
<span class="mr-3">
<a data-hovercard-user-id="3951851" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" data-hydro-click="{"event_type":"news_feed.event.click","payload":{"event":{"repo_id":2597648,"actor_id":3951851,"public":true,"type":"IssueCommentEvent","target_id":null,"id":7536739750,"additional_details_shown":false,"grouped":false},"event_group":null,"org_id":null,"target_type":"event","action_target":"actor","client_id":null,"user_id":null,"originating_request_id":"95D8:105C:3AA8D75:68286EB:5AD4EC2D"}}" data-hydro-click-hmac="166971e9a010a274823688b7e42885ab7ff197d261573cddce61393130ae374b" data-ga-click="News feed, event click, Event click type:IssueCommentEvent target:actor" href="/hucste" rel="noreferrer"><img class="avatar" src="https://avatars0.githubusercontent.com/u/3951851?s=64&v=4" width="32" height="32" alt="@hucste" data-hovercard-user-id="3951851"></a>
</span>
<div class="d-flex flex-column width-full">
<div class="d-flex flex-justify-between flex-items-baseline mb-2">
<div>
<a data-hovercard-user-id="3951851" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" data-hydro-click="{"event_type":"news_feed.event.click","payload":{"event":{"repo_id":2597648,"actor_id":3951851,"public":true,"type":"IssueCommentEvent","target_id":null,"id":7536739750,"additional_details_shown":false,"grouped":false},"event_group":null,"org_id":null,"target_type":"event","action_target":"actor","client_id":null,"user_id":null,"originating_request_id":"95D8:105C:3AA8D75:68286EB:5AD4EC2D"}}" data-hydro-click-hmac="166971e9a010a274823688b7e42885ab7ff197d261573cddce61393130ae374b" data-ga-click="News feed, event click, Event click type:IssueCommentEvent target:actor" class="link-gray-dark no-underline text-bold wb-break-all" href="/hucste" rel="noreferrer">hucste</a>
commented on
issue
<a title="Cant install on OpenBSD 6.x" class="link-gray-dark text-bold" data-hydro-click="{"event_type":"news_feed.event.click","payload":{"event":{"repo_id":2597648,"actor_id":3951851,"public":true,"type":"IssueCommentEvent","target_id":null,"id":7536739750,"additional_details_shown":false,"grouped":false},"event_group":null,"org_id":null,"target_type":"event","action_target":"issue-comment","client_id":null,"user_id":null,"originating_request_id":"95D8:105C:3AA8D75:68286EB:5AD4EC2D"}}" data-hydro-click-hmac="8017af519c829077ba7114e429209deb9cb8b5e7869b5acd94a8f140104f66d5" data-ga-click="News feed, event click, Event click type:IssueCommentEvent target:issue-comment" href="/geany/geany-plugins/issues/734#issuecomment-381636142" rel="noreferrer">geany/geany-plugins#734</a>
</div>
<span class="f6 text-gray-light ml-4">
<relative-time datetime="2018-04-16T15:04:42Z">Apr 16, 2018</relative-time>
</span>
</div>
<div class="message markdown-body Box border-gray-light p-3">
<div class="f6 mb-1">
<a title="Cant install on OpenBSD 6.x" class="link-gray" data-hydro-click="{"event_type":"news_feed.event.click","payload":{"event":{"repo_id":2597648,"actor_id":3951851,"public":true,"type":"IssueCommentEvent","target_id":null,"id":7536739750,"additional_details_shown":false,"grouped":false},"event_group":null,"org_id":null,"target_type":"event","action_target":"issue-comment","client_id":null,"user_id":null,"originating_request_id":"95D8:105C:3AA8D75:68286EB:5AD4EC2D"}}" data-hydro-click-hmac="8017af519c829077ba7114e429209deb9cb8b5e7869b5acd94a8f140104f66d5" data-ga-click="News feed, event click, Event click type:IssueCommentEvent target:issue-comment" href="/geany/geany-plugins/issues/734#issuecomment-381636142" rel="noreferrer"><img class="avatar mr-1" src="https://avatars3.githubusercontent.com/u/3951851?s=32&v=4" width="16" height="16" alt="@hucste" data-hovercard-user-id="3951851"> <span class="link-gray-dark text-bold">hucste</span> commented <relative-time datetime="2018-04-16T15:04:42Z">Apr 16, 2018</relative-time></a>
</div>
<p>But, for OpenBSD 6.2:
<code>$ clang++ -v
OpenBSD clang version 4.0.0 (tags/RELEASE_400/final) (based on LLVM 4.0.0)
Target: amd64-unknown-openbsd6.2
Thre…</code></p>
</div>
</div>
</div>
</div></div>
Bref, quel est le “meilleur” moyen, s’il en est, de parcourir le code html retourné par $item->content, pour ajouter le sheme + le nom de domaine dans l’attribut href de l’élément a, s’il n’existe pas dans cet attribut ?