Changeset 158 for table_parser
- Timestamp:
- 21/11/10 02:30:03 (18 months ago)
- File:
-
- 1 edited
-
table_parser/table_parser.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
table_parser/table_parser.py
r157 r158 51 51 def __str__(self): 52 52 return '<a href="%s">%s</a>'%(self.href, self.text) 53 def __repr__(self): 54 """Possible not the best repr""" 55 return '{"href": "%s", "text": "%s"}'%(self.href, self.text) 53 56 54 57 # Get the item on the top of a stack … … 148 151 self._buf += data 149 152 153 154 if __name__ == '__main__': 155 import sys 156 if len(sys.argv) == 2 and sys.argv[1] == '-t': 157 # Run the doctests 158 import doctest 159 doctest.testmod() 160 elif len(sys.argv) == 2: 161 # Parse the URL provided 162 import pprint 163 import urllib2 164 f = urllib2.urlopen(sys.argv[1]) 165 tp = TableParser() 166 tp.feed(f.read()) 167 f.close() 168 pprint.pprint(tp.doc) 169 else: 170 # Print usage 171 print "run doctests: <script> -t" 172 print "parse URL: <script> <URL>"
Note: See TracChangeset
for help on using the changeset viewer.
