python - What is the elegant way to get the arguments to a playAudio call from this list -


I know this is the origin.

I'm just wondering what's the best way to do it.

For example:

I want the string 'python 101.wav' and 'py * thon' from this list

The list is like this: [[('Name', 'entry']], [('class',' entry ']], [(' type ',' text / javascript '), (' ('class',' headword ')] , [('Class', '', '' '' '', 'orbit', 'pr')], [('class', 'unicode']], [('class', 'unicode']], [ ('Class', 'unicode']], [('class', 'unicode']], [], [('href', '#'), ('onclic', 'play audio (' pathon 01. '(' ',' '' ',' '' ',' Target ',' _blank ')], [(' src ',' /images/audio.gif '), (' alt ',' ('title', ' Listen to audio ' ), [('Class', 'il']], [('square', 'fl')], [], [('square', 'in')] , 'If')], [], [('class', 'DEF']], [('class', 'village']], [],]

Thanks for the help!

Probably not the biggest solution, but it appears to do so What you want:

  = [For your list [e-giant list]: # for # in each list for T: #: for each list of t: each string If s: args = s [9:] partition in 'playAudio' The ( ',') # Skip 'playAudio' comma print "% s,% s"% (args [0]. Partition [0: Args [1] .fund (')']]  

I leave the 'optimization'. If you can tell where this data is coming from and what kind of features (Playoidio can only be associated with things with HREF?), Then we can give you a better solution.

Edit:

For your specific example, I will do this personally:

  by Sundasup Imports Sunderusup, Sopstrenier Import Import urllib2 doc = urllib2.urlopen ("http://www.learnersdictionary.com/search/python") .read () doc = doc.replace ('& lt; / SCR', '') AudiLink = Sopstrainer ('a', onclick = re.compile (R'playAudio ')) Soup = [Elm in beautiful soup [Elm] for soup in the soup for Elm: print reed (r'playAudio \ ( (*. * [^]])) ', Elm). Group (1) # Print 'dragon 101.wav', 'py * thon'  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -