Q: Retrieving javascript file content with Python I need to retrieve a JavaScript file content with Python. I thought that maybe requests would do the trick - perhaps it does but it's either not as straightforward as I thought or I'm doing something wrong.
import requests
s = requests.Session()
r = s.get(link)

The response I get is
<HTML><HEAD>
<TITLE>Invalid URL</TITLE>
</HEAD><BODY>
<H1>Invalid URL</H1>
The requested URL "&#91;no&#32;URL&#93;", is invalid.<p>
Reference&#32;&#35;9&#46;3e1151c8&#46;1484072058&#46;308a223a
</BODY></HTML>

What I need it's the same that what this code does in php,
$ch = curl_init();      
curl_setopt($ch, CURLOPT_URL, $link);
$html = curl_exec($ch);


A: You need to do a http get request
import urllib2
link = "http://whatever.com/your-file.js"
urllib2.urlopen(link).read()

The php code is using curl which is doing alot more than it looks
