xmltv/grab Get_nice.pm,1.36,1.37

Nick Morrott via xmltv-commit <[email protected]> Tue, 12 Sep 2017 00:39:00 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27643/grab

Modified Files:
	Get_nice.pm 
Log Message:
get_nice_tree: pass config options to HTML::TreeBuilder as a hashref


Index: Get_nice.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/Get_nice.pm,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** Get_nice.pm	16 Feb 2017 15:35:59 -0000	1.36
--- Get_nice.pm	12 Sep 2017 00:38:58 -0000	1.37
***************
*** 37,40 ****
--- 37,41 ----
  # 0.005067 : new method post_nice_json()
  # 0.005070 : skip get_nice sleep for cached pages
+ # 0.005070 : support passing HTML::TreeBuilder options via a hashref
  our $VERSION = 0.005070;
  
***************
*** 72,81 ****
  # Fetch page and return as HTML::Tree object.
  # Optional arguments:
! # i) a function to put the page data through (eg, to clean up bad
! # characters) before parsing.
! # ii) convert incoming page to UNICODE using this codepage (use "UTF-8" for  strict utf-8)
  #
! sub get_nice_tree( $;$$ ) {
!     my ($uri, $filter, $codepage) = @_;
      require HTML::TreeBuilder;
      my $content = get_nice $uri;
--- 73,85 ----
  # Fetch page and return as HTML::Tree object.
  # Optional arguments:
! #   i) a function to put the page data through (eg, to clean up bad characters)
! #      before parsing.
! #  ii) convert incoming page to UNICODE using this codepage (use "UTF-8" for
! #      strict utf-8)
! # iii) a hashref containing options to configure the HTML::TreeBuilder object 
! #      before parsing
  #
! sub get_nice_tree( $;$$$ ) {
!     my ($uri, $filter, $codepage, $htb_opts) = @_;
      require HTML::TreeBuilder;
      my $content = get_nice $uri;
***************
*** 87,93 ****
          $content = decode('UTF-8', $content);
      }
      my $t = HTML::TreeBuilder->new();
! 		$t->ignore_unknown(!$IncludeUnknownTags);
! 		$t->parse($content) or die "cannot parse content of $uri\n";
      $t->eof;
      return $t;
--- 91,103 ----
          $content = decode('UTF-8', $content);
      }
+ 
      my $t = HTML::TreeBuilder->new();
!     $t->ignore_unknown(!$IncludeUnknownTags);
! 
!     if (ref $htb_opts eq 'HASH') {
!         $t->$_($htb_opts->{$_}) foreach (keys %$htb_opts);
!     }
! 
!     $t->parse($content) or die "cannot parse content of $uri\n";
      $t->eof;
      return $t;


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot