Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, yeah, you should probably be using an HTML parser. Here's some sample code using the HTMLParser module that comes with Python:</p> <pre><code>from HTMLParser import HTMLParser class ImgSrcHTMLParser(HTMLParser): def __init__(self): HTMLParser.__init__(self) self.srcs = [] def handle_starttag(self, tag, attrs): if tag == 'img': self.srcs.append(dict(attrs).get('src')) parser = ImgSrcHTMLParser() parser.feed(html) for src in parser.srcs: print src </code></pre> <p>This collects the src from img tags. It should be pretty easy to adapt it to your purposes assuming you want the href of 'a' tags that end in '.mp3'.</p> <p>Assuming you really want to use a regex, there are some issues with your regex. You aren't delimiting the URL and you're using dot inside the URL. The worst side-effect of this is that a non-mp3 URL followed by an mp3-URL will be treated as one long URL. eg: "<a href="http://foo/bar.gif" rel="nofollow noreferrer">http://foo/bar.gif</a> snarf snarf <a href="http://baz/quux.mp3" rel="nofollow noreferrer">http://baz/quux.mp3</a>". You probably want to require some kind of delimiter (spaces, quotes, depends on what you're doing) and disallow some characters inside URLs (probably the same characters and/or any characters that aren't allowed in URLs). Also, you forgot to escape the "." in ".mp3". So "<a href="http://foo/mp3icon.gif" rel="nofollow noreferrer">http://foo/mp3icon.gif</a>" will match as "<a href="http://foo/mp3" rel="nofollow noreferrer">http://foo/mp3</a>".</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload