from bs4 import BeautifulSoup
import urllib

url = 'https://hg.python.org/cpython/file/2.7/Lib/'
soup = BeautifulSoup(url)

def get_url(url):
    start = urllib.urlopen(url)
    soup = BeautifulSoup(start)
    for link in soup.findAll('a', href=True):
        href = link['href']
        split = href.split("/")
        try:
            index_akhir = split[5]
            if index_akhir[-3] == '.':
                print index_akhir
            else:
                pass
        except IndexError:
            pass
        
get_url(url)

"""RESULTS
>>> 
BaseHTTPServer.py
Bastion.py
CGIHTTPServer.py
ConfigParser.py
Cookie.py
DocXMLRPCServer.py
HTMLParser.py
MimeWriter.py
Queue.py
SimpleHTTPServer.py
SimpleXMLRPCServer.py
SocketServer.py
StringIO.py
UserDict.py
UserList.py
UserString.py
_LWPCookieJar.py
_MozillaCookieJar.py
__future__.py
__phello__.foo.py
_abcoll.py
_osx_support.py
_pyio.py
_strptime.py
_threading_local.py
_weakrefset.py
abc.py
aifc.py
antigravity.py
anydbm.py
argparse.py
ast.py
asynchat.py
asyncore.py
atexit.py
audiodev.py
base64.py
bdb.py
binhex.py
bisect.py
cProfile.py
calendar.py
cgi.py
cgitb.py
chunk.py
cmd.py
code.py
codecs.py
codeop.py
collections.py
colorsys.py
commands.py
compileall.py
contextlib.py
cookielib.py
copy.py
copy_reg.py
csv.py
dbhash.py
decimal.py
difflib.py
dircache.py
dis.py
doctest.py
dumbdbm.py
dummy_thread.py
dummy_threading.py
filecmp.py
fileinput.py
fnmatch.py
formatter.py
fpformat.py
fractions.py
ftplib.py
functools.py
genericpath.py
getopt.py
getpass.py
gettext.py
glob.py
gzip.py
hashlib.py
heapq.py
hmac.py
htmlentitydefs.py
htmllib.py
httplib.py
ihooks.py
imaplib.py
imghdr.py
imputil.py
inspect.py
io.py
keyword.py
linecache.py
locale.py
macpath.py
macurl2path.py
mailbox.py
mailcap.py
markupbase.py
md5.py
mhlib.py
mimetools.py
mimetypes.py
mimify.py
modulefinder.py
multifile.py
mutex.py
netrc.py
new.py
nntplib.py
ntpath.py
nturl2path.py
numbers.py
opcode.py
optparse.py
os.py
os2emxpath.py
pdb.py
pickle.py
pickletools.py
pipes.py
pkgutil.py
platform.py
plistlib.py
popen2.py
poplib.py
posixfile.py
posixpath.py
pprint.py
profile.py
pstats.py
pty.py
py_compile.py
pyclbr.py
pydoc.py
quopri.py
random.py
re.py
repr.py
rexec.py
rfc822.py
rlcompleter.py
robotparser.py
runpy.py
sched.py
sets.py
sgmllib.py
sha.py
shelve.py
shlex.py
shutil.py
site.py
smtpd.py
smtplib.py
sndhdr.py
socket.py
sre.py
sre_compile.py
sre_constants.py
sre_parse.py
ssl.py
stat.py
statvfs.py
string.py
stringold.py
stringprep.py
struct.py
subprocess.py
sunau.py
sunaudio.py
symbol.py
symtable.py
sysconfig.py
tabnanny.py
tarfile.py
telnetlib.py
tempfile.py
textwrap.py
this.py
threading.py
timeit.py
toaiff.py
token.py
tokenize.py
trace.py
traceback.py
tty.py
types.py
urllib.py
urllib2.py
urlparse.py
user.py
uu.py
uuid.py
warnings.py
wave.py
weakref.py
webbrowser.py
whichdb.py
xdrlib.py
xmllib.py
xmlrpclib.py
zipfile.py
>>> 
"""
