Python urlopen "expected string or buffer"
<p>I am getting the "expected string or buffer" error in my simple python file. I am trying to get the titles of reddit articles written down.</p>

<pre><code>from urllib import urlopen
import re


worldNewsPage = urlopen("https://www.reddit.com/r/worldnews/")

collectTitle = re.compile('&lt;p class="title"&gt;&lt;a.*&gt;(.*)&lt;/a&gt;')

findTitle = re.findall(collectTitle, worldNewsPage)

listIterator = []
listIterator[:] = range(1,3)

for i in listIterator:
    print findTitle
    print
</code></pre>

<p>Urlopen is an object so you have to call the method read to get the contents you downloaded (like files).</p>

python rss