Skip to content

Commit

Permalink
Fix celebrity thumb
Browse files Browse the repository at this point in the history
Signed-off-by: Ein Verne <einverne@gmail.com>
  • Loading branch information
einverne committed Jul 21, 2018
1 parent 9a69fad commit 0d0ec12
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
douban downloader
=======================

一个简单的下载豆瓣相册、图集、影人图片的小脚本

A simple python script to download douban albums and celebrity


Expand All @@ -23,6 +25,10 @@ Introduction
douban-dl https://www.douban.com/people/einverne/


4. 电影剧照

douban-dl https://movie.douban.com/subject/26804147

Installation
------------

Expand All @@ -42,6 +48,8 @@ Usage

`path` is the folder where images saved, defaults to `./douban`.

如果没有指定 `path` ,默认会保存到当前目录下 douban 文件夹中。

License
-------

Expand Down
17 changes: 14 additions & 3 deletions douban/celebrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,28 @@ def photos(self):
# https://img3.doubanio.com/view/photo/thumb/public/p2156276775.jpg
# https://img3.doubanio.com/view/photo/raw/public/p2156276775.jpg
# https://img3.doubanio.com/view/photo/photo/public/p2156276775.webp
yield photo.a['href'], photo.img['src'].replace("photo/thumb", "photo/raw")
# src https://img3.doubanio.com/view/photo/m/public/p2179264053.webp
src = photo.img['src']
if 'm/public' in src:
src = src.replace("photo/m", "photo/raw")
if 'photo/thumb' in src:
src = src.replace("photo/thumb", "photo/raw")
if 'webp' in src:
src = src.replace("webp", "jpg")
yield photo.a['href'], src
start += step

def __photos(self, start):
params = {
"type": "C",
"start": start,
"sortby": "vote",
"sortby": "like",
"size": "a",
"subtype": "a"
}
r = requests.get(self.url, params=params)
header = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
}
r = requests.get(self.url, params=params, headers=header)
soup = BeautifulSoup(r.text, "html.parser")
return soup.find_all("div", class_="cover")

0 comments on commit 0d0ec12

Please sign in to comment.