我试图从一个网站上抓取有关圣经注解的信息。下面是我为此所做的代码。start_urls
是我试图抓取的json文件的链接。我选择了['0']['father']['_id']
来获取评论者的名称,但是,出现了下面的错误。我该怎么办?
错误:TypeError: list indices must be integers or slices, not str
编码:
import scrapy
import json
class catenaspider(scrapy.Spider): #spider to crawl the url
name = 'commentary' #name to be called in command terminal
start_urls = ['https://api.catenabible.com:8080/anc_com/c/mt/1/1?tags=[%22ALL%22]&sort=def']
def parse(self,response):
data = json.loads(response.body)
yield from data['0']['father']['_id']```
1条答案
按热度按时间osh3o9ms1#
请再次阅读文档。