Is it possible to retrieve a Javascript file from a server?
<p>In Python, I can retrieve Javascript from an HTML document using the following code.</p>

<pre><code>import urllib2, jsbeautifier
from bs4 import BeautifulSoup

f = urllib2.urlopen("http://www.google.com.ph/")

soup = BeautifulSoup(f, "lxml")
script_raw = str(soup.script)

script_pretty = jsbeautifier.beautify(script_raw)
print(script_pretty)
</code></pre>

<p>But how about if the script comes from a Javascript file on the server, like:</p>

<pre><code>&lt;script src="some/directory/example.js" type="text/javascript"&gt;
</code></pre>

<p>Is it possible to retrieve "example.js"? If so, how?</p>

<p>Context: I'm examining the Javascript of phishing web pages.</p>

<p>If you want to load at run time, like some part of your javascript is dependent on other javascript, then for loading javascript at run time, you can use require.js .</p>

javascript python