Write excel file within Scrapy project

Asked

Viewed 48 times

-2

I have a Spider that picks up the xlsx links, in Request I call the files and saved in:

def save_file(self, response):

    f = open("teste.xls", "wb")

    f = write(response.body)

    f.close()

But returns the error:

f = write(response.body)

Nameerror: name 'write' is not defined

Can someone help me solve this problem?

  • 1

    Shouldn’t be f.write? You need to call a method, not overwrite the object.

  • True man, thanks already worked out.

1 answer

0


def save_file(self, response):

f = open("teste.xls", "wb")

f.write(response.body)

f.close()

You were wrong in

f = write(response.body)

you have assigned the variable "f" the write() value, but write is not a function.

  • Richard, try to explain what you’ve done, otherwise the person might not understand.

  • Thanks for the tip

Browser other questions tagged

You are not signed in. Login or sign up in order to post.