Quantcast
Channel: Active questions tagged feedparser - Stack Overflow
Viewing all articles
Browse latest Browse all 105

How to cycle through indices

$
0
0

so in this script I am writing to learn python, I would like to just put a wildcard instead of rewriting this whole block just to change line 2. what would be the most efficient way to consolidate this into a loop, where it will just use all d.entries[0-99].content and repeat until finished? if, while, for?also my try /except does not perform as expectedwhat gives?

import feedparser, base64from urlextract import URLExtract d = feedparser.parse('https://www.reddit.com/r/PkgLinks.rss')print (d.entries[3].title)sr = str(d.entries[3].content)spl1 = sr.split("<p>")ss = str(spl1)spl2 = ss.split("</p>")try:    st = str(spl2[0])#    print(st)except:     binascii.Error    st = str(spl2[1])    print(st)#st = str(spl2[0])spl3 =st.split("', '")stringnow=str(spl3[1])b64s1 = stringnow.encode('ascii')b64s2 = base64.b64decode(b64s1)stringnew = b64s2.decode('ascii')print(stringnew)## but line 15 does nothing, how to fix and also loop through all d.entries[?].content

Viewing all articles
Browse latest Browse all 105

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>