hengqiaqia 2019-07-01
我这里使用的是uni-app框架(多端发布的一款框架,基于vue语法,正在踩坑中)
onLoad() { uni.request({ url: 'http://api.douban.com/v2/movie/in_theaters', method: 'GET', data: {}, success: res => { console.log(res) }, fail: () => {}, complete: () => {} }); },
来看看返回了什么:
location /v2/ { proxy_store off; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Referer 'no-referrer-when-downgrade'; proxy_set_header User-Agent 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; proxy_pass https://api.douban.com/v2/; }
http://api.douban.com
为https://douban.uieee.com
,https://douban.uieee.com
是某大佬搭建的代理,相当于别人替你去做了方法一的事情,你只需要搬过来用就行了。header:{ // 下面这两个时好时坏,有些时候突然碰到400,请求头换一下就好了,这个问题我也无解 // "Content-Type":"application/xml" "content-type":"json" },
onLoad() { uni.request({ url: 'https://douban.uieee.com/v2/movie/in_theaters', method: 'GET', header:{ "Content-Type":"application/xml" }, data: { start: 0, count: 4, city: '杭州' }, success: res => { console.log(res) }, fail: () => {}, complete: () => {} }); },
https://douban.uieee.com/v2/movie/in_theaters
start : 数据的开始项
count:单页条数
city:城市
https://douban.uieee.com/v2/movie/top250
start : 数据的开始项
count:单页条数
https://douban.uieee.com/v2/movie/coming_soon
start : 数据的开始项
count:单页条数
https://douban.uieee.com/v2/movie/search
start : 数据的开始项
count:单页条数
q:要搜索的电影关键字
tag:要搜索的电影的标签
https://douban.uieee.com/v2/movie/subject/:id
https://api.douban.com/v2/movie/subject/25924056
https://douban.uieee.com/v2/movie/weekly?apikey=0df993c66c0c636e29ecbb5344252a4a
https://douban.uieee.com/v2/movie/us_box?apikey=0df993c66c0c636e29ecbb5344252a4a
https://douban.uieee.com/v2/movie/new_movies?apikey=0df993c66c0c636e29ecbb5344252a4a
https://douban.uieee.com/v2/movie/celebrity/:id/photos?apikey=0df993c66c0c636e29ecbb5344252a4a
https://douban.uieee.com/v2/movie/subject/:id/photos?apikey=0df993c66c0c636e29ecbb5344252a4a
https://douban.uieee.com/v2/music/search?q=欧美&count=15?
https://douban.uieee.com/v2/music/:id
https://douban.uieee.com/v2/book/search?q=虚构类&count=8
https://douban.uieee.com/v2/book/search?q=非虚构类&count=8
https://douban.uieee.com/v2/book/search?q=旅行&count=8
https://douban.uieee.com/v2/movie/subject/:id/comments?start=xxx&count=xxx&apikey=0df993c66c0c636e29ecbb5344252a4a