In Python, I can retrieve Javascript from an HTML document using the following 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)
But how about if the script comes from a Javascript file on the server, like:
<script src="some/directory/example.js" type="text/javascript">
Is it possible to retrieve "example.js"? If so, how?
Context: I'm examining the Javascript of phishing web pages.