Stars: 115
Forks: 21
Pull Requests: 3
Issues: 17
Watchers: 1
Last Updated: 2022-06-30 06:36:34
基于thinkphp5.1的豆瓣电影API
License: MIT License
Languages: PHP, PLpgSQL, Smarty
pip install doubanlib
from doubanlib.movies import DouBan
from doubanlib.movies import MovieInfo
# Set the headers
headers = {'User-Agent': 'Hello'}
DouBan.set_headers(headers=headers)
# You can also set the optional proxy
# DouBan.set_proxy(proxy={'http': '203.89.126.250:80'})
# Doctor Strange in the Multiverse of Madness which id is 30304994(https://movie.douban.com/subject/30304994)
obj = MovieInfo(30304994)
# Print the description of the movie
print('Description:{}'.format(obj.description))
# Print all the information of the movie.
print(
'ID:{}\nName:{}\nChinese_Name:{}\nYear:{}\nGenre:{}\nRegions:{}\nLanguage:{}\nRating:{}\nVotes:{}\nLength_Movie:{}\nDirectors:{}\nAlias:{}\nImage:{}\nDate_Published:{}\nActors:{}\nDescription:{}'
.format(obj.m_id, obj.name, obj.chineseName, obj.year, obj.genre,
obj.regions, obj.languages, obj.rating, obj.votes, obj.length_movie,
obj.directors, obj.alias, obj.image, obj.pubDate, obj.actors,
obj.actors, obj.description))
下载代码
git clone https://github.com/xhboke/douban.git
启动服务
php think run
然后就可以在浏览器中访问
http://localhost:8000
上传代码,设置 public
为运行目录,设置伪静态
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
同时关闭调试模式 /config/app.php
: 'app_debug' => true
==> 'app_debug' => false
频繁使用会导致封禁IP,目前可通过更换IP或者使用代理或者是登录获取Cookie的方式避免。
上方为豆瓣的链接,下方是API的链接,大致相同,涉及页数的有变化,最后请不要加上‘/’
https://movie.douban.com/subject/25845392/
http://127.0.0.1:8000/subject/25845392
https://movie.douban.com/subject/25845392/comments?status=P
http://127.0.0.1:8000/subject/25845392/comments?page=0&sort=new_score
https://movie.douban.com/subject/25845392/reviews?&start=0&sort=hotest
http://127.0.0.1:8000/subject/25845392/reviews?page=0&sort=hotest
https://movie.douban.com/subject/25845392/celebrities
http://127.0.0.1:8000/subject/25845392/celebrities
https://movie.douban.com/subject/25845392/all_photos
http://127.0.0.1:8000/subject/25845392/all_photos
https://movie.douban.com/subject/25845392/photos?type=S
http://127.0.0.1:8000/subject/25845392/photos?type=S
http://127.0.0.1:8000/search/key/长津湖
https://search.douban.com/movie/subject_search?search_text=长&cat=1002&start=0
http://127.0.0.1:8000/search/长/0
http://127.0.0.1:8000/tag?tags=电影,剧情,中国大陆,2021&page=0&sort=U
https://movie.douban.com/celebrity/1023040
http://127.0.0.1:8000/celebrity/1023040
https://movie.douban.com/celebrity/1023040/photos/?type=C&start=0&sortby=like&size=a&subtype=a
http://127.0.0.1:8000/celebrity/1023040/photos?page=0&sort=like
https://movie.douban.com/celebrity/1023040/photo/1247932516
http://127.0.0.1:8000/celebrity/1023040/photo/1247932516
https://movie.douban.com/celebrity/1023040/awards
http://127.0.0.1:8000/celebrity/1023040/awards
https://movie.douban.com/celebrity/1023040/movies?start=0&format=pic&sortby=time
http://127.0.0.1:8000/celebrity/1023040/movies?page=0&sort=time
https://movie.douban.com/celebrity/1023040/movies?start=0&format=pic&sortby=time
http://127.0.0.1:8000/celebrity/1023040/partners?page=0
https://movie.douban.com/photos/photo/2673813691/
http://127.0.0.1:8000/photos/photo/2673813691
https://movie.douban.com/top250?start=25&filter=
http://127.0.0.1:8000/top250?page=0
本项目仅供学习交流,禁止用于非法用途。