Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change &#39 into normal character

I'm having trouble displaying content, my program:

#! /usr/bin/python

import urllib
import re

url = "http://yahoo.com"
pattern = '''<span class="medium item-label".*?>(.*)</span>'''

website = urllib.urlopen(url)
pageContent = website.read()
result = re.findall(pattern, pageContent)

for record in result:
    print record

output:

Masked teen killed by dad
First look in &#39;Hotel of Doom&#39;
Ex-NFL QB&#39;s sad condition
Reporter ignores warning
Romney&#39;s low bar for debates

So the question is what should I include in my code in order to transform &#39 into characters

like image 682
Vor Avatar asked Sep 28 '12 19:09

Vor


People also ask

What is a better word for change?

adjustment, advance, development, difference, diversity, innovation, modification, reversal, revision, revolution, shift, switch, transformation, transition, variation, turnaround, adjust, alter, diminish, evolve.

Why is change so important?

Change Ensures That Bad Situations End So long as you embrace change, you will find that your situation does not have to last forever and you will progress on to something bigger and better. If you reject change, experiences and opportunities in your career are likely to pass you by.

What is life change?

Change allows us to move forward in life and experience new and exciting things. When you don't actively work on evolving yourself, life can become stagnant. Learning new skills or working on your inner self can bring about changes you never knew were possible.

What is change example?

Examples of chemical changes are burning, cooking, rusting, and rotting. Examples of physical changes are boiling, melting, freezing, and shredding. Many physical changes are reversible, if sufficient energy is supplied.


1 Answers

The solution for Python 3,

import html
html.unescape(text)
like image 103
Abhishek Avatar answered Sep 30 '22 06:09

Abhishek