***Editted: added second problem
I have this code, how do I make it stop once it's found the first instance of the if happening. break, myparser.close(), and return don't work.
from html.parser import HTMLParser
class MyHTMLParser(HTMLParser):
def handle_starttag(self, tag, attrs):
if tag == 'a' and (attrs[0][1].find('downloads&showfile') != -1):
print(attrs[0][1])
print(attrs[1][1])
info = open('download.txt', 'r').read()
myparser = MyHTMLParser()
myparser.feed(info)
2.
I have this code, How do i make it so blahblah is the name of hte file i downloaded. The name of the file is not shown in the url.
file = urllib.request.urlopen('http://beta.getdota.com/index.php?app=downloads&module=display§ion=download&do=confirm_download&id=' + current)
output = open(blahblah ,'wb')
output.write(file.read())
output.close()