错误 400 - 尝试使用 Scrapy 项目在 Soundcloud 中设置 q 搜索参数时出现错误请求

error 400 - bad request when trying to set q search parameter in Soundcloud with Scrapy item

我正在尝试在 soundcloud 中搜索与艺术家姓名相关的曲目。如果我只是在 q 搜索参数中键入一个艺术家姓名,它就可以完美地工作,但是我希望它使用一个项目 ['artist'] 变量。我认为可能是一个简单的编程错误导致 'bad request' 错误。这是相关代码。谢谢大家!!

def parse_me(self, response):
    for info in response.xpath('//div[@class="entry vevent"]'):
        item = TutorialItem() # Extract items from the items folder.
        item ['artist'] = info.xpath('.//span[@class="summary"]//text()').extract() # Extract artist information.
        #item ['genre'] = info.xpath('.//div[@class="header"]//text()').extract()
        yield item # Retreive items in item
        client = soundcloud.Client(client_id='xxxx', client_secret='xxxx', callback='http://localhost:9000/#/callback.html')
        tracks = client.get('/tracks', q=item['artist'], limit=1)
        for track in tracks:
            print track.id
            item ['trackz'] = track.id
            yield item

info.xpath('.//span[@class="summary"]//text()').extract() returns 一个列表。您的 q 参数可能需要一个字符串。