我在scrapy+python中工作。我试过从jobid中提取jobid数据,任何人都可以指导我提取这个。你知道吗
http://xxxxx/apply/EkhIMG/Director-Financial-Planning-Analysis.html
我要单独摘录这篇内容“主任财务规划分析”
还需要删除特殊字符太DirectorFinancialPlanningAnalysis
我的预期结果应该是:董事财务计划分析
我的蜘蛛代码是:
hxs = Selector(response)
item = response.request.meta['item']
item ['JobDetailUrl'] = response.url
item ['InternalJobId'] = item ['JobDetailUrl'].re('.*\/(.*?)\.html').groups()
我的输出错误:
item ['InternalJobId'] = item['JobDetailUrl'].re('.*\/(.*?)\.html')
.groups()
exceptions.AttributeError: 'str' object has no attribute 're'
re()
是Selector
对象上的方法,这里response.url
是字符串:演示:
相关问题 更多 >
编程相关推荐