Scapy中的python回调语法错误

2024-09-26 22:10:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我有下面的代码,我正在运行。获取python语法时出错。我在python2.7.10中使用Mac。有什么不对劲吗?我对python比较陌生

语法错误:语法无效 callback='parse_项'

完整代码:

# -*- coding: utf-8 -*-
import scrapy

from scrapy.spiders import CrawlSpider
from scrapy.spiders import Rule
from scrapy.linkextractors import Linkextractors

class MpuDivsSpider(CrawlSpider):
    name = 'mpu_divs'
    allowed_domains = ['www.capitalfm.com']
    start_urls = ['http://www.capitalfm.com/']

#http://www.capitalfm.com/music-news/kylie-jenner-outcast-not-made-for-fame/
#http://www.capitalfm.com/artists/adele/news/grenfell-kids-cinema/
#http://www.capitalfm.com/music-news/week-photos/7-august-2017/justin-bieber/
#http://www.capitalfm.com/music-news/week-photos/7-august-2017/leigh-anne-pinnock/
    rules = [

        Rule(LinkExtractor(allow=[r'/7-august-2017/\w*'])
        callback='parse_item',
        follow = True)
    ]

    def parse_item(self, response):
        print response.url

Tags: 代码fromimportcomhttpparsewwwcallback

热门问题