Loading external pagesΒΆ

Plugins can be made to load external webpages:

from portal.pluginbase.core import *

from portal.generic.plugin_interfaces import IPluginBlock

class MyBlockPlugIn(Plugin):
    """ PLUGIN EXAMPLE
        This plugin will return the google.com page in to
        the pluginblock "myblock"
    """

    implements(IPluginBlock)

    def __init__(self):
        self.name = "myblock"
        self.plugin_guid = '53D22AB9-EDB6-4388-8A9A-D752A81D7040'

    def return_string(self, tagname, *args):
        from urllib.request import urlopen
        f = urlopen("http://www.google.com")
        encoding = f.headers['content-type'].split('charset=')[-1]
        s = str(f.read(), encoding)
        f.close()
        return s

pluginblock1 = MyBlockPlugIn()