how to save(write) webpage soure in html.?

10 views
Skip to first unread message

masroor javed

unread,
Apr 11, 2014, 3:51:43 AM4/11/14
to scrapy...@googlegroups.com
Hi,

I am new here in scrapy.
Please suggest me how to save(write) a webpage in hml form using spider code.


how will i save or write in html?


please let me know.

Pablo Hoffman

unread,
Apr 11, 2014, 7:42:23 AM4/11/14
to scrapy-users
If you just want to save the response body to an "output.html" file you can do this in a spider callback:

def parse(self, response):
    with open("output.html") as f:
        f.write(response.body)


--
You received this message because you are subscribed to the Google Groups "scrapy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scrapy-users...@googlegroups.com.
To post to this group, send email to scrapy...@googlegroups.com.
Visit this group at http://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.

masroor javed

unread,
Apr 11, 2014, 7:47:49 AM4/11/14
to scrapy...@googlegroups.com
Thanks Pablo.
could you tell me how to get response from save file.
Means i jst want to extract or work only write html(save html) page, i don wanna hit webpage again n again thats why i am asking 
about can we get contents of save file?
EX: firstly i write a page in html name output.html
2: i want to start output.html page instead of start_urls.
is this possible?

Reply all
Reply to author
Forward
0 new messages