0

hi i am trying to find the best way to extract values from a string returned from feedparser, basically its returning the following, i can of course do a regex match but im sure there is a better way.

xml looks like this:-

<description>
   Size: 2247 MB People: 5,951 Hash: 9df49c5de014df3b5f202f51dc849b37cf82a3ad
</description>

result from feedparser looks like this:-

 Size: 2247 MB People: 5,951 Hash: 9df49c5de014df3b5f202f51dc849b37cf82a3ad

so basically i want Size, People, and Hash values e.g.

2247
5,951
9df49c5de014df3b5f202f51dc849b37cf82a3ad

ive read up as much as i can about doing this and im not 100% sure on my teminology but i think this is related to namespace?.

binhex
  • 374
  • 4
  • 13

1 Answers1

0
import re

s = "Size: 2247 MB People: 5,951 Hash: 9df49c5de014df3b5f202f51dc849b37cf82a3ad"
arr = re.split('Size: |People: |Hash: ', s)
arr = [x.strip() for x in arr][1:]
print arr

Output ['2247 MB', '5,951', '9df49c5de014df3b5f202f51dc849b37cf82a3ad']

Issam Zoli
  • 2,724
  • 1
  • 21
  • 35
  • thanks for the post, so im assuming from this there is no way i can get to the values using feedparser without doing some sort of string manipulation using regex? – binhex Aug 11 '14 at 15:53
  • I don't think so, description it's not formated following any standard I know – Issam Zoli Aug 11 '14 at 15:56