How to extract text between 2 unique phrases and put into ordered list using python?
<p>I have a text file with a lot of lines in it and there are multiple instances of the phrase alpha and bravo, id like to extract everything in between those phrases and have it put into a list in a new text file.
For example, say the source.txt file read</p>

<pre><code>&lt;ul class="_539vh _4j13h"&gt;&lt;li class="_cx1ua"&gt;&lt;div class="_6jvgy"&gt;
&lt;div class="_9tu8m"&gt;&lt;a class="_5lote _pfo25 _vbtk2" href="/dog/" style="width: 30px; height: 30px;"&gt;
&lt;img class="_a012k" src=""&gt;&lt;/a&gt;
&lt;div class="_mmgca"&gt;&lt;div class="_gzjax"&gt;&lt;a class="_4zhc5 notranslate _j7lfh" title="dog" href="/cat/"&gt;cat&lt;/a&gt;&lt;/div&gt;
</code></pre>

<p>In this case alpha would be href="/ and bravo would be /" and I would want the list produced to read something like</p>

<pre><code>dog
cat
</code></pre>

<p>How would i be able to do this, I am very new to coding.</p>

<p>One code I found online and tried so far is </p>

<pre><code>inFile = open("source.txt")
outFile = open("List.txt", "w")
buffer = []
keepCurrentSet = True
for line in inFile:
    buffer.append(line)
    if line.startswith('href="/'):
        #href="/ starts a new data set
        if keepCurrentSet:
            outFile.write("".join(buffer))
        #now reset our state
        keepCurrentSet = False
        buffer = []
    elif line.startswith('/"'):
        keepCurrentSet = True
inFile.close()
outFile.close()
</code></pre>