WebBrowser/Tools/Scripts.py

branch
QtWebEngine
changeset 4758
c973eef8fef1
parent 4749
750577d35452
child 4766
5f8d08aa2217
diff -r 1ff6d0ecb2fd -r c973eef8fef1 WebBrowser/Tools/Scripts.py
--- a/WebBrowser/Tools/Scripts.py	Sat Feb 20 15:25:51 2016 +0100
+++ b/WebBrowser/Tools/Scripts.py	Sat Feb 20 17:31:34 2016 +0100
@@ -351,3 +351,36 @@
     data = bytes(data).decode("utf-8")
     data = data.replace("'", "\\'")
     return source.format(data)
+
+###########################################################################
+## scripts below are specific for eric
+###########################################################################
+
+
+def getFeedLinks():
+    """
+    Function generating a script to extract all RSS and Atom feed links.
+    
+    @return script to extract all RSS and Atom feed links
+    @rtype str
+    """
+    source = """
+        (function() {
+            var out = [];
+            var links = document.getElementsByTagName('link');
+            for (var i = 0; i < links.length; ++i) {
+                var e = links[i];
+                if ((e.rel == 'alternate') &&
+                    ((e.type == 'application/atom+xml') ||
+                     (e.type == 'application/rss+xml')
+                    )
+                   ) {
+                    out.push({
+                        url: e.getAttribute('href'),
+                        title: e.getAttribute('title')
+                    });
+                }
+            }
+            return out;
+        })()"""
+    return source

eric ide

mercurial