aboutsummaryrefslogtreecommitdiff
path: root/bridges/LegifranceJOBridge.php
diff options
context:
space:
mode:
Diffstat (limited to 'bridges/LegifranceJOBridge.php')
-rw-r--r--bridges/LegifranceJOBridge.php64
1 files changed, 34 insertions, 30 deletions
diff --git a/bridges/LegifranceJOBridge.php b/bridges/LegifranceJOBridge.php
index 2d86c2ce..cf8f9f72 100644
--- a/bridges/LegifranceJOBridge.php
+++ b/bridges/LegifranceJOBridge.php
@@ -14,6 +14,37 @@ class LegifranceJOBridge extends BridgeAbstract
private $timestamp;
private $uri;
+ public function collectData()
+ {
+ $html = getSimpleHTMLDOM(self::URI);
+
+ $title = $html->find('h2.titleJO', 0);
+
+ //$this->author = trim($title->plaintext);
+ $uri1 = $html->find('h2.titleELI', 0);
+ //$uri = $uri1->plaintext;
+ //$this->uri = trim(substr($uri, strpos($uri, 'https')));
+ $this->timestamp = strtotime(substr($this->uri, strpos($this->uri, 'eli/jo/') + strlen('eli/jo/'), -5));
+
+ foreach ($html->find('h3') as $section) {
+ $subsections = $section->nextSibling()->find('h4');
+ foreach ($subsections as $subsection) {
+ $origins = $subsection->nextSibling()->find('h5');
+ foreach ($origins as $origin) {
+ $this->items[] = $this->extractItem($section, $subsection, $origin);
+ }
+ if (!empty($origins)) {
+ continue;
+ }
+ $this->items[] = $this->extractItem($section, $subsection);
+ }
+ if (!empty($subsections)) {
+ continue;
+ }
+ $this->items[] = $this->extractItem($section);
+ }
+ }
+
private function extractItem($section, $subsection = null, $origin = null)
{
$item = [];
@@ -35,7 +66,9 @@ class LegifranceJOBridge extends BridgeAbstract
$item['content'] = '';
foreach ($data->nextSibling()->find('a') as $content) {
$text = $content->plaintext;
- $href = $content->nextSibling()->getAttribute('resource');
+ $href = '';
+ //$href = $content->nextSibling()->getAttribute('resource');
+
$item['content'] .= '<p><a href="' . $href . '">' . $text . '</a></p>';
}
return $item;
@@ -45,33 +78,4 @@ class LegifranceJOBridge extends BridgeAbstract
{
return 'https://www.legifrance.gouv.fr/img/favicon.ico';
}
-
- public function collectData()
- {
- $html = getSimpleHTMLDOM(self::URI)
- or $this->returnServer('Unable to download ' . self::URI);
-
- $this->author = trim($html->find('h2.titleJO', 0)->plaintext);
- $uri = $html->find('h2.titleELI', 0)->plaintext;
- $this->uri = trim(substr($uri, strpos($uri, 'https')));
- $this->timestamp = strtotime(substr($this->uri, strpos($this->uri, 'eli/jo/') + strlen('eli/jo/'), -5));
-
- foreach ($html->find('h3') as $section) {
- $subsections = $section->nextSibling()->find('h4');
- foreach ($subsections as $subsection) {
- $origins = $subsection->nextSibling()->find('h5');
- foreach ($origins as $origin) {
- $this->items[] = $this->extractItem($section, $subsection, $origin);
- }
- if (!empty($origins)) {
- continue;
- }
- $this->items[] = $this->extractItem($section, $subsection);
- }
- if (!empty($subsections)) {
- continue;
- }
- $this->items[] = $this->extractItem($section);
- }
- }
}