[Tutor] Beautifulsoup4 question

Juan Christian juan0christian at gmail.com
Thu Oct 2 00:56:58 CEST 2014


I have this part of the code - full_item_list = self._soup.find_all('li',
{'data-app': '440'}) - that gives me this:

Very long output (~ 211 lines): http://pastebin.com/WLTtgVZz

Now I need to filter this RAW data, what I need is to convert this data to
something like a list of dicts in Python, so that I can do, let's say...

for item in data:
    item['data-name'] > returns > 'Mann Co. Supply Crate'
    item['data-p-bptf'] > returns > '0.01 ref'
    item['image'] > returns > 'URL_TO_IMG'
    item['data-original-id'] > returns > '2713101947'

and so on...

It would be a list of dicts, each item in the list would be one "<li> item
already parsed/filtered", and inside each list item I'd have a dict with
these info. Is there something in bs4 that does that, or maybe a different
module?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141001/7a6a4e64/attachment.html>


More information about the Tutor mailing list