| @@ 132-151 (lines=20) @@ | ||
| 129 | } |
|
| 130 | ||
| 131 | // Fallback for title |
|
| 132 | if ($this->useFallbackMode && !$object->title) { |
|
| 133 | $titleElement = $crawler->filter("title")->first(); |
|
| 134 | if ($titleElement->count()) { |
|
| 135 | $object->title = trim($titleElement->text()); |
|
| 136 | } |
|
| 137 | ||
| 138 | if (!$object->title) { |
|
| 139 | $titleElement = $crawler->filter("h1")->first(); |
|
| 140 | if ($titleElement->count()) { |
|
| 141 | $object->title = trim($titleElement->text()); |
|
| 142 | } |
|
| 143 | } |
|
| 144 | ||
| 145 | if (!$object->title) { |
|
| 146 | $titleElement = $crawler->filter("h2")->first(); |
|
| 147 | if ($titleElement->count()) { |
|
| 148 | $object->title = trim($titleElement->text()); |
|
| 149 | } |
|
| 150 | } |
|
| 151 | } |
|
| 152 | ||
| 153 | // Fallback for description |
|
| 154 | if ($this->useFallbackMode && !$object->description) { |
|
| @@ 154-173 (lines=20) @@ | ||
| 151 | } |
|
| 152 | ||
| 153 | // Fallback for description |
|
| 154 | if ($this->useFallbackMode && !$object->description) { |
|
| 155 | $descriptionElement = $crawler->filter("meta[property='description']")->first(); |
|
| 156 | if ($descriptionElement->count()) { |
|
| 157 | $object->description = trim($descriptionElement->attr("content")); |
|
| 158 | } |
|
| 159 | ||
| 160 | if (!$object->description) { |
|
| 161 | $descriptionElement = $crawler->filter("meta[name='description']")->first(); |
|
| 162 | if ($descriptionElement->count()) { |
|
| 163 | $object->description = trim($descriptionElement->attr("content")); |
|
| 164 | } |
|
| 165 | } |
|
| 166 | ||
| 167 | if (!$object->description) { |
|
| 168 | $descriptionElement = $crawler->filter("p")->first(); |
|
| 169 | if ($descriptionElement->count()) { |
|
| 170 | $object->description = trim($descriptionElement->text()); |
|
| 171 | } |
|
| 172 | } |
|
| 173 | } |
|
| 174 | ||
| 175 | return $object; |
|
| 176 | } |
|