Regex required or can BeautifulSoup refine output
<p>If I use the following function I can grab the text and link I need from a website:</p>

<pre><code>def get_url_text(url):
    source = requests.get(url)
    plain_text = source.text
    soup = BeautifulSoup(plain_text)
    for item_name in soup.findAll('li', {'class': 'ptb2'}):
        print(item_name.string)
        print (item_name.a)

get_url_text('https://www.residentadvisor.net/podcast.aspx')
</code></pre>

<p>returns:</p>

<pre><code>RA.532 Marquis Hawkes
&lt;a href="/podcast-episode.aspx?id=532"&gt;&lt;h1&gt;RA.532 Marquis Hawkes&lt;/h1&gt;&lt;/a&gt;
RA.531 Evan Baggs
&lt;a href="/podcast-episode.aspx?id=531"&gt;&lt;h1&gt;RA.531 Evan Baggs&lt;/h1&gt;&lt;/a&gt;
RA.530 MCDE vs Jeremy Underground
</code></pre>

<p>If I only want the href link instead of the tags etc surrounding it do I need to use a regex or is there another method within BeautifulSoup?</p>

<p>Desired output is:</p>

<pre><code>RA.532 Marquis Hawkes
https://www.residentadvisor.net/podcast-episode.aspx?id=532
</code></pre>

<p>for each similar element.</p>

<p>you can use <code>print(item_name.a['href'])</code> and (if needed) prepend the prefix <code>https://www.residentadvisor.net</code> (since the links in the webpage are used in a form without explicit scheme and netloc part - for example, <code>/podcast-episode.aspx?id=528</code>)</p>

python