1

I'm using urllib2 to open and read two external web pages and then saving them to django's internal cache, like so:

header = urllib2.urlopen( "http://www.mysite.com/pageheader.html" ).read()
footer = urllib2.urlopen( "http://www.mysite.com/pagefooter.html" ).read()

cache.add( 'header', header )
cache.add( 'footer', footer )

I then retrieve these from cache and pass them as template variables:

integration = cache.get_many[('header','footer')]

The problem appears to be non-ascii characters in one of the fragments preventing it from displaying on the template. These seem to be smart quotes and in vim they appear as:

We<92>ve or <93>Tumultuous<94> or just <97>

Since I have no access to the remote server, is there a way when grabbing these fragments that I can convert these problems before saving them to cache?

wmfox3
  • 2,141
  • 4
  • 21
  • 28

1 Answers1

0

Check if urllib2 can properly encode retrieved page, more here:

urllib2 read to Unicode

Community
  • 1
  • 1
n3storm
  • 704
  • 8
  • 21