Last active
September 25, 2020 09:53
-
-
Save Rigel772/d90c17461dce8d1070a75bf1d1e1d2d9 to your computer and use it in GitHub Desktop.
[scrapy save html page] #scrapy #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Write all site html | |
| class Spider(scrapy.Spider): | |
| name = "posts" | |
| start_urls = [ | |
| 'https://blog.scrapinghub.com/page/1/', | |
| 'https://blog.scrapinghub.com/page/2/' | |
| ] | |
| def parse(self, response): | |
| page = response.url.split('/')[-1] | |
| filename = 'posts-%s.html' % page | |
| with open(filename, 'wb') as f: | |
| f.write(response.body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment