2012-03-23 1 views
1

기본적으로 Django 모델에서 피드 URL을 거의 저장하지 않으며 구문 분석을 위해 모델에서 검색 한 URL은 구문 분석되지 않습니다. 아래는 어떻게 모델을 쿼리하고 피드 파서를 사용하여 URL을 구문 분석하려고하는지입니다.Django 및 Feedparser - 모델에서 쿼리 된 URL을 구문 분석 할 수 없습니다.

>>> from bit.models import * 
>>> url = feednfo.objects.filter(iD=1).values('feed_url') 
>>> url 
>>> [{'feed_url': u'http://www.popgadget.net/atom.xml'}] 
>>> import feedparser as fp 
>>> feed = fp.parse(url) 
>>> feed 
>>>{'feed': {}, 'bozo': 1, 'bozo_exception': TypeError('coercing to Unicode: need string or buffer, ValuesQuerySet found',), 'entries': []} 
>>> feed = fp.parse('http://www.popgadget.net/atom.xml') 
>>> feed.bozo 
>>>0 

누구나 잘못 알 수 있습니까? 문자열 또는 유니 코드 형식과 관련하여 문제가 있습니까?

답변

0

dict의 목록을 feedparser.parse()에 전달하고 있습니다.

feed = fp.parse(url) 

같은인가 :

그건

feed = fp.parse([{'feed_url': u'http://www.popgadget.net/atom.xml'}]) 

은 다음과 같아야합니다

feed = fp.parse(u'http://www.popgadget.net/atom.xml') 
+0

감사합니다 :

feed = fp.parse(url[0]['feed_url']) 

이 같을 톤 버디. U 말이 맞아. 그것은 효과가 있었다. – Anshuma

+0

[닫기 질문] (http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) – jpic

+0

죄송합니다, 형편 없음. 나는 그 일을 잊어 버렸다. – Anshuma