title: Extracting text from script tag using BeautifulSoup in Python
body: <p>I am looking to extract email, phone and name value from the below code in SCRIPT tag(not in Body) using Beautiful soup(Python). I see Beautiful soup can be used for extracting.</p>
  <p>I tried getting page using the following code -</p>
  <pre><code>fileDetails = BeautifulSoup(urllib2.urlopen('http://www.example.com').read())
  results = fileDetails.find(email:&quot;)
  </code></pre>
  <p>This Ajax request code is not repeating in the page again. Can we also write try and catch so that if it doesn't found it in the page, it won't throw any error.</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot; language='javascript'&gt; 
  $(document).ready( function (){
     
     $('#message').click(function(){
         alert();
     });
  
      $('#addmessage').click(function(){
          $.ajax({ 
              type: &quot;POST&quot;,
              url: 'http://www.example.com',
              data: { 
                  email: 'abc@g.com', 
                  phone: '9999999999', 
                  name: 'XYZ'
              }
          });
      });
  });
  </code></pre>
  <p>Once I get this, I also want to store in an excel file.</p>
  <p>Thanks in anticipation.</p>