Skip to content

Commit

Permalink
Fixed invalid filename
Browse files Browse the repository at this point in the history
- Fixed invalid filename
- Test pattern: '"%*\/:<>?\t\\|\n~-_@aBcD.epub'
  • Loading branch information
PoHsun-Su committed Nov 23, 2017
1 parent 0274c12 commit dd4157e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion safaribook/spiders/safaribooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def parse_page(self, title, bookid, path, response):
def parse_toc(self, response):
toc = eval(response.body)
self.book_name = toc['title_safe']
self.book_title = toc['title'].replace(' ','_').replace(':',' -') # to be used for filename
self.book_title = re.sub(r'["%*/:<>?\\|~\s]', r'_', toc['title']) # to be used for filename
cover_path, = re.match(r'<img src="(.*?)" alt.+', toc["thumbnail_tag"]).groups()
yield scrapy.Request(self.host + cover_path,
callback=partial(self.parse_cover_img, "cover-image"))
Expand Down

0 comments on commit dd4157e

Please sign in to comment.