Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This is a simple python script to scrape comments from a web page.
#!/usr/bin/env python
import argparse
import urllib
import urlparse
from HTMLParser import HTMLParser
arg_parser = argparse.ArgumentParser()
args = arg_parser.parse_args()
class MyParser(HTMLParser):
def handle_comment(self, data):
print 'Line ' + str(self.getpos()[0]) + ' ' + data
html_parser = MyParser()
content = urllib.urlopen(args.url).read()
except IOError:
print 'Please ensure that the URL is formatted properly'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment