0

I'm using feedparser in Python to parse a remote xml feed. Results include the typical title/link/published/etc, however there is also a "content" tag that has the following value. How can I access the value attribute?

[{'base': u'http://url.com', 'type': u'text/html', 'value': u'<p>html text etc', 'language': None}]

I haven't seen any arrays looking like [{}] before.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Joe
  • 1,762
  • 9
  • 43
  • 60

3 Answers3

3

That is just a dictionary inside a list. If you have that object as x, just do x[0]['value'].

BrenBarn
  • 242,874
  • 37
  • 412
  • 384
1

That's a list with one dictionary:

print content[0]['value']

From the feedparser documentation:

entries[i].content

A list of dictionaries with details about the full content of the entry.

Atom feeds may contain multiple content elements. Clients should render as many of them as possible, based on the type and the client’s abilities.

So, you can easily have more dictionaries in that list, or 0.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
0

According to documentation

entries[i].content
entries[i].content[j].value
entries[i].content[j].type
entries[i].content[j].language

Etc...

CptNemo
  • 6,455
  • 16
  • 58
  • 107