GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
HTML::MobileConverter(3) User Contributed Perl Documentation HTML::MobileConverter(3)

HTML::MobileConverter - HTML Converter for mobile agent

  use HTML::MobileConverter;

  my $baseuri = 'http://example.com/';
  my $c = HTML::MobileConverter->new(baseuri => $baseuri);
  my $html =<<END;
  <html><body>title<hr><a href="./my">my link</a></body></html>
  END
  print $c->convert($html); # get html with abs-uri.
  
  use URI;
  $html = <<END;
  <html><body>
  title<hr>
  <a href="./my">my link</a>
  <iframe src="./my"></iframe>
  </body></html>
  END
  $c = HTML::MobileConverter->new(
    baseuri => $baseuri,
    hrefhandler => sub {
      my $href = shift;
      return URI->new_abs($href, 'http://example.com/');
    },
  );
  print $c->convert($html); # get html without iframe.
  
  # create a proxy
  my $q = CGI->new;
  my $html = $c->convert(LWP::Simple:get($q->param('uri')));
  print Jcode->new($html)->sjis;

HTML::MobileConverter parses HTML and returns new HTML for mobile agent (mainly for DoCoMo i-mode). If the original HTML doesn't contain so many pc tags, it returns the original HTML strings with absolute uri (href,src...). If the original was guessed as a content for PC, it returns new HTML for mobile agent.

Here are common methods of HTML::MobileConverter.
new
  $c = HTML::MobileConverter->new;
  $c = HTML::MobileConverter->new(baseuri => 'http://www.example.com/');
  $c = HTML::MobileConverter->new(
    baseuri => 'http://www.example.com/',
    hrefhandler => sub {
      my $href = shift;
      $href = URI->new_abs($href, 'http://www.example.com/');
      return qq|/browse?uri=$href|;
    },
  );
    

creates a instance of HTML::MobileConverter. If you specify "baseuri", "href/src/action" attributes will be replaced with absolute uris.

If you specify "hrefhandler" with some function, href attribute will be handled with the handler.

convert
  my $mhtml = $c->convert($html);
    

returns HTML strings for mobile.

ismobilecontent
  print "is mobile" if $c->ismobilecontent;
    

returns which the original HTML was guessed as mobile content or not.

Junya Kondo, <jkondo@hatena.ne.jp>

Copyright (C) 2005 by Junya Kondo

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

HTML::Parser http://www.nttdocomo.co.jp/p_s/imode/tag/lineup.html (Japanese)
2005-08-30 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.