diff --git a/python/pyphantomjs/phantom.py b/python/pyphantomjs/phantom.py index 4d24eb05..3f38b539 100644 --- a/python/pyphantomjs/phantom.py +++ b/python/pyphantomjs/phantom.py @@ -64,6 +64,7 @@ class Phantom(QObject): self.m_defaultPageSettings['loadImages'] = args.load_images self.m_defaultPageSettings['loadPlugins'] = args.load_plugins self.m_defaultPageSettings['userAgent'] = self.m_page.userAgent() + self.m_defaultPageSettings['localAccessRemote'] = args.local_access_remote self.m_page.applySettings(self.m_defaultPageSettings) self.libraryPath = os.path.dirname(os.path.abspath(self.m_scriptFile)) diff --git a/python/pyphantomjs/pyphantomjs.py b/python/pyphantomjs/pyphantomjs.py index 7a810cd4..8004f3a5 100644 --- a/python/pyphantomjs/pyphantomjs.py +++ b/python/pyphantomjs/pyphantomjs.py @@ -60,6 +60,7 @@ def parseArgs(args): args.ignore_ssl_errors = False if args.ignore_ssl_errors == 'no' else True args.load_images = True if args.load_images == 'yes' else False args.load_plugins = False if args.load_plugins == 'no' else True + args.local_access_remote = False if args.local_access_remote == 'no' else True if args.proxy: item = args.proxy.split(':') diff --git a/python/pyphantomjs/utils.py b/python/pyphantomjs/utils.py index efd540c5..60c03b76 100644 --- a/python/pyphantomjs/utils.py +++ b/python/pyphantomjs/utils.py @@ -79,6 +79,10 @@ def argParser(): choices=['yes', 'no'], help='Load all plugins (i.e. Flash, Silverlight, ...) (default: %(default)s)' ) + parser.add_argument('--local-access-remote', default='no', + choices=['yes', 'no'], + help='Local content can access remote URL (default: %(default)s)' + ) parser.add_argument('--proxy', metavar='address:port', help='Set the network proxy' ) diff --git a/python/pyphantomjs/webpage.py b/python/pyphantomjs/webpage.py index ba584192..8e836d74 100644 --- a/python/pyphantomjs/webpage.py +++ b/python/pyphantomjs/webpage.py @@ -101,6 +101,8 @@ class WebPage(QObject): self.m_webPage.settings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True) self.m_webPage.settings().setOfflineStoragePath(QDesktopServices.storageLocation(QDesktopServices.DataLocation)) self.m_webPage.settings().setAttribute(QWebSettings.LocalStorageDatabaseEnabled, True) + self.m_webPage.settings().setAttribute(QWebSettings.OfflineWebApplicationCacheEnabled, True) + self.m_webPage.settings().setOfflineWebApplicationCachePath(QDesktopServices.storageLocation(QDesktopServices.DataLocation)) self.m_webPage.settings().setAttribute(QWebSettings.FrameFlatteningEnabled, True) self.m_webPage.settings().setAttribute(QWebSettings.LocalStorageEnabled, True) self.m_webPage.settings().setLocalStoragePath(QDesktopServices.storageLocation(QDesktopServices.DataLocation)) @@ -117,6 +119,7 @@ class WebPage(QObject): opt.setAttribute(QWebSettings.AutoLoadImages, defaults['loadImages']) opt.setAttribute(QWebSettings.PluginsEnabled, defaults['loadPlugins']) + opt.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, defaults['localAccessRemote']) if 'userAgent' in defaults: self.m_webPage.m_userAgent = defaults['userAgent']