how to get href link from onclick function in python
<p>I want to get href link of website form onclick function 
Here is html code in which onclick function call a website </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="fl"&gt;
  &lt;span class="taLnk" onclick="ta.trackEventOnPage('Eatery_Listing', 'Website', 594024, 1); ta.util.cookie.setPIDCookie(15190); ta.call('ta.util.link.targetBlank', event, this, {'aHref':'LqMWJQzZYUWJQpEcYGII26XombQQoqnQQQQoqnqgoqnQQQQoqnQQQQoqnQQQQoqnqgoqnQQQQoqnQQuuuQQoqnQQQQoqnxioqnQQQQoqnQQ2EisSMVCnVcJQQoqnQQQQoqnxioqnQQQQoqnQQniaQQoqnQQQQoqnqgoqnQQQQoqnQQWJQzhYMJkH3KHVAdJJH3VVdB', 'isAsdf':true})"&gt;Website&lt;/span&gt; 
&lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p>Normaly i use this code to get href link from any span or element</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>geturl = soup.findsoup("span", {"class": "taLnk"})
for link in geturl:
  hreflink = link.get("href")
  print(hreflink)</code></pre>
</div>
</div>
</p>

<p>But in this case there is no way to directly call href because href exist in onclick function</p>

<p>Please help me what to do now</p>

<p>You cannot directly parse <code>aHref</code> attribute, you need to extract <code>onclick</code> first.</p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt; data = soup.select('.taLnk')[0].get('onclick')
&gt;&gt;&gt; href = re.search(r"(?is)'aHref':'(.*?)'",str(data)).group(1)
'LqMWJQzZYUWJQpEcYGII26XombQQoqnQQQQoqnqgoqnQQQQoqnQQQQoqnQQQQoqnqgoqnQQQQoqnQQuuuQQoqnQQQQoqnxioqnQQQQoqnQQ2EisSMVCnVcJQQoqnQQQQoqnxioqnQQQQoqnQQniaQQoqnQQQQoqnqgoqnQQQQoqnQQWJQzhYMJkH3KHVAdJJH3VVdB'
</code></pre>

python html python-3.x beautifulsoup