WebBrowser/Tools/Scripts.py

branch
QtWebEngine
changeset 4783
7de17766a5df
parent 4766
5f8d08aa2217
child 4847
a1a8eac81b54
diff -r 4ad656e4ebec -r 7de17766a5df WebBrowser/Tools/Scripts.py
--- a/WebBrowser/Tools/Scripts.py	Sun Feb 28 12:48:12 2016 +0100
+++ b/WebBrowser/Tools/Scripts.py	Sun Feb 28 15:23:42 2016 +0100
@@ -158,6 +158,29 @@
     return source.format(pos.x(), pos.y())
 
 
+def getAllImages():
+    """
+    Function generating a script to extract all image tags of a web page.
+    
+    @return script to extract image tags
+    @rtype str
+    """
+    source = """
+        (function() {
+            var out = [];
+            var imgs = document.getElementsByTagName('img');
+            for (var i = 0; i < imgs.length; ++i) {
+                var e = imgs[i];
+                out.push({
+                    src: e.src,
+                    alt: e.alt
+                });
+            }
+            return out;
+        })()"""
+    return source
+
+
 def getAllMetaAttributes():
     """
     Function generating a script to extract all meta attributes of a web page.
@@ -174,7 +197,8 @@
                 out.push({
                     name: e.getAttribute('name'),
                     content: e.getAttribute('content'),
-                    httpequiv: e.getAttribute('http-equiv')
+                    httpequiv: e.getAttribute('http-equiv'),
+                    charset: e.getAttribute('charset')
                 });
             }
             return out;

eric ide

mercurial