-
-
Save netdesign/1242105 to your computer and use it in GitHub Desktop.
Why This?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def dataExtractor(node): | |
| XMLNS_D = '{http://purl.org/dc/elements/1.0/}' | |
| elem = tr.fromstring(node) | |
| title = elem.find(XMLNS_D + 'Title').text | |
| if title is not None: | |
| title = title | |
| else: | |
| title = "nnn" | |
| descr = elem.find(XMLNS_D + 'Description').text | |
| if descr is not None: | |
| descr = descr | |
| else: | |
| descr = "nnn" | |
| url = elem.attrib['about'] | |
| row = [url, title, descr] | |
| return row | |
| curs.executemany('INSERT INTO dmoz (url, title, descr) VALUES(?, ?, ?)', [dataExtractor(theChunk[i]) for i in theChunk]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Traceback (most recent call last): | |
| File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap | |
| self.run() | |
| File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run | |
| self._target(*self._args, **self._kwargs) | |
| File "xmlFasterParser.py", line 73, in xmlParser | |
| curs.executemany('INSERT INTO dmoz (url, title, descr) VALUES(?, ?, ?)', [dataExtractor(theChunk[i]) for i in theChunk]) | |
| TypeError: list indices must be integers, not str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment