UnicodeEncode Error ?

2009-03-11 Thread Rama Vadakattu
While doing the below

1) fetch  html page
2) extract title using BeatifulSoup
3) Save into the database.

iam getting the below error (at the bottom).

Few observations which i had:
 1) type of variable which holds this title is 
 2) iam getting this problem when the title has character whose
ordinal value > 128

I searched in google and tried various suggestions but none of them is
working.And also i couldnot able to understand the rootcause for such
a kind of behaviour.

What will be the root cause for such a kind of problem?Any hint on how
to resolve this error?

~~~
Error
--
Traceback (most recent call last):
  File "fetchcron.py", line 11, in 
cmanager.triggerfetchFeed()
  File "/home/rama/djangoprojects/socialreader/views.py", line 40, in
triggerfetchFeed
self.fetchFeed(furl)
  File "/home/rama/djangoprojects/socialreader/views.py", line 102, in
fetchFeed
ne.save()
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 311, in save
self.save_base(force_insert=force_insert,
force_update=force_update)
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 383, in save_base
result = manager._insert(values, return_id=update_pk)
  File "/usr/lib/python2.5/site-packages/django/db/models/manager.py",
line 138, in _insert
return insert_query(self.model, values, **kwargs)
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 894, in insert_query
return query.execute_sql(return_id)
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/
subqueries.py", line 309, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/
query.py", line 1734, in execute_sql
cursor.execute(sql, params)
  File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
  File "/usr/lib/python2.5/site-packages/django/db/backends/mysql/
base.py", line 83, in execute
return self.cursor.execute(query, args)
  File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line
151, in execute
query = query % db.literal(args)
  File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
line 247, in literal
return self.escape(o, self.encoders)
  File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
line 180, in string_literal
return db.string_literal(obj)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xc9' in
position 1: ordinal not in range(128)
---
--
http://mail.python.org/mailman/listinfo/python-list


how to get the summarized text from a given URL?

2009-03-24 Thread Rama Vadakattu
Is there any python library to solve the below problem?

FOr the below URL :
--
http://tinyurl.com/dzcwbg

Summarized text is :
---
By Roy Mark With sales plummeting and its smart phones failing to woo
new customers, Sony Ericsson follows its warning that first quarter
sales will be disappointing with the announcement that Najmi Jarwala,
president of Sony Ericsson USA and head of ...

~~
Usually summarized text is a  2 to 3 line description of the URL which
we usually obtain by fetching that html page , examining the  content
and  figuring out short description from that html markup.
~

Are there any python libraries which give summarized text for a given
url ?

It is ok even if the library  just gives  intial two lines of text
from the given URL Instead of summarization.
--
http://mail.python.org/mailman/listinfo/python-list