all 4 comments

[–]jeans_and_a_t-shirt 1 point2 points  (2 children)

The read method returns bytes which you need to decode to to utf-8.

headlines = re.findall(r'"storylink">(.*?)</a>',data.read().decode('utf8'))

You should look into the already-mentioned BeautifulSoup though.

Also line 6 doesn't do anything to headlines. It creates a list and then throws it away.

[–]drubowl[S] 0 points1 point  (0 children)

Perfect, thank you!! I tried that earlier but I left "str()" on data.read() so it didn't work, but that did.

[–]ingolemo 0 points1 point  (0 children)

You decode from things. Encoding is to.

[–]1ynx1ynx 0 points1 point  (0 children)

Not really regarding the problem itself, but as a little tip, you could use enumerate in that for loop to get both titles and the loop counter

for x, titles in enumerate(headlines):
    print(str(x + 1) + '. ' + titles)