| 232 | | |
|---|
| | 232 | } |
|---|
| | 233 | |
|---|
| | 234 | if ($self->{extract_xpath}) { |
|---|
| | 235 | eval { require HTML::TreeBuilder::XPath }; |
|---|
| | 236 | if ($@) { |
|---|
| | 237 | Plagger->context->log(error => "HTML::TreeBuilder::XPath is required. $@"); |
|---|
| | 238 | return; |
|---|
| | 239 | } |
|---|
| | 240 | |
|---|
| | 241 | my $tree = HTML::TreeBuilder::XPath->new; |
|---|
| | 242 | $tree->parse($args->{content}); |
|---|
| | 243 | $tree->eof; |
|---|
| | 244 | |
|---|
| | 245 | for my $capture (keys %{$self->{extract_xpath}}) { |
|---|
| | 246 | my @children = $tree->findnodes($self->{extract_xpath}->{$capture}); |
|---|
| | 247 | $data->{$capture} = $children[0]->as_HTML; |
|---|
| | 248 | } |
|---|
| | 249 | } |
|---|
| | 250 | |
|---|
| | 251 | if ($data) { |
|---|