搜索自考資料,在網上搜了下這些文檔都是能夠隨便看,可是下載要錢的javascript
先找目標網址 https://max.book118.com/html/2016/1224/76473555.shtmhtml
不用登錄,耶耶耶java
方法一json
雖然頁面禁止右鍵行爲,可是隻要瀏覽器禁止頁面js或者是打開改單獨圖片地址就行了瀏覽器
settingsapp
而後經過右鍵保存,可是數量太多了,想一想就麻煩ui
不如作點啥吧。url
方法二htm
發現是一個iframe,那打開看看好了,就到了下面的頁面blog
那我只須要第一個接口的信息,後面的接口參數就都有了
打開單張圖片地址發現返回的參數就是圖片的完整連接參數的一部分
下面看粗糙代碼
var superagent = require('superagent'); var fs = require("fs"); var i = 0;//文件名 function test(imgs){//下載圖片 var _img = '7o@o7xcocmkL_slKMQRJ7BmfZy6MmpTR2LRhppJrt@1YmiPLbwQiPSyNJDH6cy0dKYx_OqO5XxA='//第一張圖片的部分地址 if(imgs){ _img = imgs } var saveImg = 'https://view57.book118.com/img/?img='+_img//須要下載的圖片地址 superagent .get(saveImg) .send({ img:_img }) .end((err,res)=>{ console.log('img==='+res.body) res.setEncoding("binary") i++; var tmp = "./aa/"+ i +".png" fs.writeFile(tmp, res.body, "binary", function (err) { if (err) { return console.error(err); }else{ console.log("保存成功"); setTimeout(function(){//作人低調 getUrl(_img); },1500) } }); }) } function getUrl(_img){//獲取圖片地址參數 superagent .get('https://view57.book118.com/pdf/GetNextPage/?f=RjpcT2ZmaWNlV2ViMzY1XE9mZmljZVdlYlxjYWNoZVxQREZcMTE2MTIyNDE0MDMyMzEzMjUwMjEwMTQ1NDVfMTgxMjQ4XDIxMTM0MzUtNTg1ZTBmYWI0Njk4Yi5kb2MudGVtcA%3D%3D&img=7o%40o7xcocmkL_slKMQRJ7BmfZy6MmpTR2LRhppJrt%401YmiPLbwQiPfCa5XE1j4YCnc1NXftPWUs%3D&isMobile=false&isNet=True&readLimit=m05GD%40CZT1P0GOn8Lv_JjQ%3D%3D&furl=o4j9ZG7fK96K7ALNwHnKKQSGvsVp16t3OGQ8hCU%40qfk6tlpWD7Ja6aejeMBHDc30Bl0SYXklcX15I0vqB0%40iSi0tdf2506q8tknYr5_l2nM%3D') .set('Accept','application/json, text/javascript, */*; q=0.01') .set('Content-Type','application/json; charset=utf-8') .set('Connection','keep-alive') .set('Cookie','__cfduid=d36900c15ce242f30af1efa4ffa36dae31522302561; CLIENT_SYS_UN_ID=3rvhcVv2CTUEqq/kHfvAAg==; Hm_lvt_5d91dc9c92e499ab00ba867fc2294136=1542852289,1542852292,1542855730; Hm_lpvt_5d91dc9c92e499ab00ba867fc2294136=1542855772') .set('Host','view57.book118.com') .set('Referer','https://view57.book118.com/pdf/dXAxNS5ib29rMTE4LmNvbS44MFwyMTEzNDM1LTU4NWUwZmFiNDY5OGIuZG9j?readpage=m05GD%40CZT1P0GOn8Lv_JjQ%3D%3D&furl=o4j9ZG7fK96K7ALNwHnKKQSGvsVp16t3OGQ8hCU%40qfk6tlpWD7Ja6aejeMBHDc30Bl0SYXklcX15I0vqB0%40iSi0tdf2506q8tknYr5_l2nM%3D&token=PDWfni5ovTsVBbpwUGR6QPhtBOXaydS6') .set('User-Agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36') .set('X-Requested-With','XMLHttpRequest') .send({ img:_img }) .end((err,response)=>{ var res = JSON.parse(response.text) console.log(res.NextPage);//拿到下個接口須要的參數 test(res.NextPage) }) } test();
下面是部分結果