#Practice Code: James Troost import urllib import re def getname(): s = input("File name: ") return s def getext(filename): return filename[filename.index(".") + 1 : len(filename)] def getstart(extension): return extension[0 : 1] def getsource(weblink): return urllib.urlopen(weblink) filename = getname() extension = getext(filename) first = getstart(extension) print "Extension: " + extension + "\n" regex = r'"_blank">' + extension.upper() + '</a></td>.*\n.*<td>(.+?)</td>' cregex = re.compile(regex) weblink = "http://filext.com/alphalist.php?extstart=%5E" + first.upper() websource = getsource(weblink) htmltext = websource.read() description = re.findall(cregex,htmltext) print "Source:" + weblink + "\n" print "Your file is one of the following:" for words in description: print "\nA(n)" + words + "\n"
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question