python - Simple scrapy XML spider syntax error -


i trying make simple spider using scrapy grab data xml file. came with:

from scrapy.contrib.spiders import xmlfeedspider  class myspider(xmlfeedspider):      name = 'testproject'      allowed_domains = ['www.w3schools.com']      start_urls = ['http://www.w3schools.com/xml/note.xml']      itertag = 'note'      def parse_node(self, response, node):          = node.select('to/text()').extract()          = node.select('from/text()').extract()          heading  = node.select('heading/text()').extract()          body  = node.select('body/text()').extract()      def parse_node(self, response, node):          log.msg('hi, <%s> node!: %s' % (self.itertag, ''.join(node.extract())))          item = item()          item['to'] = node.select('to').extract()          item['from'] = node.select('from').extract()          item['heading'] = node.select('heading').extract()          item['body'] = node.select('body').extract()          return item 

this data set: http://www.w3schools.com/xml/note.xml

when try , run it, unfortunately doesn't work. think it's related how mapping tags. error:

  file "/usr/local/bin/scrapy", line 11, in <module>                                                         sys.exit(execute())                                                                                    file "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 143, in execute                      _run_print_help(parser, _run_command, cmd, args, opts)                                                 file "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 89, in _run_print_help               func(*a, **kw)                                                                                         file "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 150, in _run_command                 cmd.run(args, opts)                                                                                    file "/usr/local/lib/python2.7/dist-packages/scrapy/commands/crawl.py", line 57, in run                    crawler = self.crawler_process.create_crawler()                                                        file "/usr/local/lib/python2.7/dist-packages/scrapy/crawler.py", line 87, in create_crawler                self.crawlers[name] = crawler(self.settings)                                                           file "/usr/local/lib/python2.7/dist-packages/scrapy/crawler.py", line 25, in __init__                      self.spiders = spman_cls.from_crawler(self)                                                            file "/usr/local/lib/python2.7/dist-packages/scrapy/spidermanager.py", line 35, in from_crawler            sm = cls.from_settings(crawler.settings)                                                               file "/usr/local/lib/python2.7/dist-packages/scrapy/spidermanager.py", line 31, in from_settings           return cls(settings.getlist('spider_modules'))                                                         file "/usr/local/lib/python2.7/dist-packages/scrapy/spidermanager.py", line 22, in __init__                module in walk_modules(name):                                                                      file "/usr/local/lib/python2.7/dist-packages/scrapy/utils/misc.py", line 68, in walk_modules               submod = import_module(fullpath)                                                                       file "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module                                 __import__(name)                                                                                       file "/var/www/spider/crawler/spiders/jobsite.py", line 11                                                 = node.select('from/text()').extract()                                                                   ^                                                                                               syntaxerror: invalid syntax  

any appreciated.

change word from different, in python keyword.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -