I know this is a newbie question, and it's a basic Python question, but it's within the context of Scrapy and I can't find the answer anywhere.
When I run this bot code:
import scrapy
from tutorial.items import DmozItem
class DmozSpider(scrapy.Spider):
    name = "dmoz"
    allowed_domains = ["lib-web.org"]
    start_urls = [
        "http://www.lib-web.org/united-states/public-libraries/michigan/"
    ]
    count = 0
    def increment(self):
        global count
        count += 1
    def getCount(self):
        global count
        return count
    def parse(self, response):
        increment()
        for sel in response.xpath('//div/div/div/ul/li'):
            item = DmozItem()
            item['title'] = sel.xpath('a/text()').extract()
            item['link'] = sel.xpath('a/@href').extract()
            item['desc'] = sel.xpath('p/text()').extract()
            x = getCount()
            print x
            yield item
DmozItem:
import scrapy
class DmozItem(scrapy.Item):
    title = scrapy.Field()
    link = scrapy.Field()
    desc = scrapy.Field()
I get this error:
File "/Users/Admin/scpy_projs/tutorial/tutorial/spiders/dmoz_spider.py", line 23, in parse
    increment()
NameError: global name 'increment' is not defined
Why I can't call increment() from within parse(self, response)? How can I make this work?
Thanks for any help.
 
     
    