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>Change</p>

<pre><code>worldNewsPage = urlopen("https://www.reddit.com/r/worldnews/")
</code></pre>

<p>to</p>

<pre><code>worldNewsPage = urlopen("https://www.reddit.com/r/worldnews/").read()
</code></pre>

<p>Also <a href="http://stackoverflow.com/a/1732454/1219006">don't use <code>regex</code> to parse <code>html</code></a>. You can use  <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="nofollow"><code>BeautifulSoup</code></a></p>

python rss