多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
![](http://imgs.bizha.top//5042624492ea0ab6ccce2a50ea23c094) ### 一、爬虫遇到的问题 1. 需要下载付费部分,因此需要登录。否则无法获取链接。 2. 链接`token`有时限,需要即时下载,否则会过期。 `https://vb1.ating.info/fiction/wuxia/feitian/3euezgrd.mp3?token=oS8IWpFYAUnP1SZKF6GjFg**_6J_cScZL-7S3cfeRCJbWVt6GkPEtL-0_&e=1587737779216&t=2&res=970411484&sign=76e85feabf8878bf935a64e41344b7c7` ![](http://imgs.bizha.top//cda6966d757d3d778daf1b923d0041d8) 3. 文件名具有特殊符号,无法保存。 ### 二、爬虫实现 1. 用`requests`的模块保持链接`.session()`。 ```python LoginUrl = 'https://m.lrts.me/ajax/logon' conn = requests.session() PostData = {"account":account,"pwd":ba_password} rep = conn.post(LoginUrl, data=PostData) repJson = json.loads(rep.text) msg = repJson['msg'] if msg =='账号或密码错误': print('帐号或密码错误,仅下载免费部分') else: print('登录成功,下载该帐号免费部分及购买部分') ``` 2. 即时调用下载软件下载。 ```python IdmPath = 'C:\Program Files (x86)\Internet Download Manager\IDMan.exe' def IdmDownLoad(DownloadUrl, Mp3Name): call([IdmPath, '/d',DownloadUrl,'/p',FilePath,'/f',Mp3Name,'/n']) ``` 3. replace**替换**所有特殊字符。 def ChangeFileName(filename): ```python def ChangeFileName(filename): filename = filename.replace('\\','') filename = filename.replace('/','') filename = filename.replace(':','') filename = filename.replace('*','') filename = filename.replace('“','') filename = filename.replace('”','') filename = filename.replace('<','') filename = filename.replace('>','') filename = filename.replace('|','') filename = filename.replace('?','?') filename = filename.replace('(','(') filename = filename.replace(chr(65279),'') # UTF-8+BOM filename = filename.split('(')[0] return filename ``` ### 三、爬虫实现。 `https://github.com/yoval/lrts`(需设定好time.sleep) ![](http://imgs.bizha.top//f456b959b1a16c4c1451cec758256cd1)