title: Python: BeautifulSoup - extract value from location.href=
body: <p>I encountered a problem statement where I need to print the value &quot;input.php?id=293&quot; of the key &quot;location.href=&quot; from the code.</p>
  <pre><code>&lt;script&gt;location.href=&quot;input.php?id=293&quot;;&lt;/script&gt;
  </code></pre>
  <p>I have tried the below code but stuck in the end.</p>
  <pre><code>import requests
  from bs4 import BeautifulSoup
  import re
  
  url = https://localhost/sample.php
  response = requests.get(url)
  soup = BeautifulSoup(response.text, features=&quot;lxml&quot;)
  value = soup.find_all(text=re.compile(r'location.href'))
  print (value)
  </code></pre>
  <p>Any help will be appreciated.</p>