-2

Im trying to search soundcloud for a track related to an artists name. It works perfectly if i just type an artist name in the q search parameter, however i want it to use an item ['artist'] variable. I think theres prbably a simple programming error which is causing the 'bad request' error. Here is the relevant code. Thanks guys!!

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

1 Answers1

0

info.xpath('.//span[@class="summary"]//text()').extract() returns a list. Your q parameter probably requires a string.

marven
  • 1,836
  • 1
  • 17
  • 14