1
Я очищаю информацию с некоторых веб-сайтов событий. Я получил эту ошибку, когда я запустил своего паука, мне было интересно, если кто-нибудь новый, как его решить.Scrapy informatio не JSON serializable
File "/usr/lib/python3.4/json/encoder.py", line 173, in default raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <Selector xpath='.//a[@target="_top"]/text()' data='Artist Development Fellowship Informatio'> is not JSON serializable
я могу очистить текст:
scrapy shell http://ofa.fas.harvard.edu/events
for event in response.xpath('.//article[@class="node node-event node-teaser article event-start clearfix"]'):
event.xpath('.//a[@target="_top"]/text()')
паук:
import scrapy
class FAS(scrapy.Spider):
name ='fas'
start_urls = [
'http://ofa.fas.harvard.edu/events',
]
def parse(self, response):
for event in response.xpath('.//article[@class="node node-event node-teaser article event-start clearfix"]'):
yield {
'title' : event.xpath('.//a[@target="_top"]/text()'),
}