defparse_item(self,response):"""
Parses response and saves
response.url to file output.txt
"""x=HtmlXPathSelector(response)# this makes sure the file is closed
# when the context of the operation
# is no more.
# f.writeline() writes each value in a newline
# no need to format the string.
withopen("output.txt","ab")asf:f.writeline(response.url)
Happy coding!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great post! I hope you don't mind if I suggest a little tweak to the code. :)
This method:
To this:
Happy coding!