我有下面的代码,我正在运行。获取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
您在
19
行的末尾忘了一个,
:相关问题 更多 >
编程相关推荐