| @@ 123-142 (lines=20) @@ | ||
| 120 | $object->assignProperties($properties, $this->debug); |
|
| 121 | ||
| 122 | // Fallback for title |
|
| 123 | if ($this->useFallbackMode && !$object->title) { |
|
| 124 | $titleElement = $crawler->filter("title")->first(); |
|
| 125 | if ($titleElement->count()) { |
|
| 126 | $object->title = trim($titleElement->text()); |
|
| 127 | } |
|
| 128 | ||
| 129 | if (!$object->title) { |
|
| 130 | $titleElement = $crawler->filter("h1")->first(); |
|
| 131 | if ($titleElement->count()) { |
|
| 132 | $object->title = trim($titleElement->text()); |
|
| 133 | } |
|
| 134 | } |
|
| 135 | ||
| 136 | if (!$object->title) { |
|
| 137 | $titleElement = $crawler->filter("h2")->first(); |
|
| 138 | if ($titleElement->count()) { |
|
| 139 | $object->title = trim($titleElement->text()); |
|
| 140 | } |
|
| 141 | } |
|
| 142 | } |
|
| 143 | ||
| 144 | // Fallback for description |
|
| 145 | if ($this->useFallbackMode && !$object->description) { |
|
| @@ 145-164 (lines=20) @@ | ||
| 142 | } |
|
| 143 | ||
| 144 | // Fallback for description |
|
| 145 | if ($this->useFallbackMode && !$object->description) { |
|
| 146 | $descriptionElement = $crawler->filter("meta[property='description']")->first(); |
|
| 147 | if ($descriptionElement->count()) { |
|
| 148 | $object->description = trim($descriptionElement->attr("content")); |
|
| 149 | } |
|
| 150 | ||
| 151 | if (!$object->description) { |
|
| 152 | $descriptionElement = $crawler->filter("meta[name='description']")->first(); |
|
| 153 | if ($descriptionElement->count()) { |
|
| 154 | $object->description = trim($descriptionElement->attr("content")); |
|
| 155 | } |
|
| 156 | } |
|
| 157 | ||
| 158 | if (!$object->description) { |
|
| 159 | $descriptionElement = $crawler->filter("p")->first(); |
|
| 160 | if ($descriptionElement->count()) { |
|
| 161 | $object->description = trim($descriptionElement->text()); |
|
| 162 | } |
|
| 163 | } |
|
| 164 | } |
|
| 165 | ||
| 166 | return $object; |
|
| 167 | } |
|