用python爬虫爬取无水印图片_用 Python 下载抖音无水印视频 编辑:佚名 日期:2024-01-08 21:23 / 人气: 抖音无水印视频的下载可以通过调用API接口实现。可以使用Python或Java编写相关代码。 Python实现: ``` import requests import json url='https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?itemId=' item_id='视频ID' headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' } response=requests.get(url=url+item_id, headers=headers) data=json.loads(response.text) video_url=data['item_list'][0]['video']['play_addr']['url_list'][0] video=requests.get(video_url, headers=headers) with open('video.mp4', 'wb') as f: f.write(video.content) ``` Java实现: ``` import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; public class DownloadVideo { public static void main(String[] args) throws IOException { String url="https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?itemId="; String item_id="视频ID"; String user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"; String video_url=""; URL real_url=new URL(url+item_id); HttpURLConnection connection=(HttpURLConnection) real_url.openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("User-Agent", user_agent); connection.setRequestProperty("Accept", "**"); connection.setRequestProperty("Content-Type", "application/octet-stream"); connection.setRequestProperty("Connection", "keep-alive"); connection.connect(); in=connection.getInputStream(); FileOutputStream out=new FileOutputStream("video.mp4"); while((len=in.read(buf))!=-1){ out.write(buf,0,len); } in.close(); out.close(); } } ``` 注意:以上代码仅供学习参考,请勿用于非法用途。 上一篇:抖音广告费用多少?投放广告又要找谁? ← 下一篇:打通基层消防安全“最后一公里”“火凤凰”消防志愿者在行动 → 内容搜索 Related Stories 推荐内容 Recommended 美术生出国读研哪里好_五大国家盘点01-08 关于申报国家留学基金委2024年度艺术类人才培养特别项目立项的通知01-08 考研常识:哪些专业考英语一,哪些考英语二?01-08 张雪峰推荐十大好专业:十大冷门但是高薪的专业01-08 不适合女生学的专业有哪些?附张雪峰最不建议上的专业女生12-13
抖音无水印视频的下载可以通过调用API接口实现。可以使用Python或Java编写相关代码。 Python实现: ``` import requests import json url='https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?itemId=' item_id='视频ID' headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' } response=requests.get(url=url+item_id, headers=headers) data=json.loads(response.text) video_url=data['item_list'][0]['video']['play_addr']['url_list'][0] video=requests.get(video_url, headers=headers) with open('video.mp4', 'wb') as f: f.write(video.content) ``` Java实现: ``` import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; public class DownloadVideo { public static void main(String[] args) throws IOException { String url="https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?itemId="; String item_id="视频ID"; String user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"; String video_url=""; URL real_url=new URL(url+item_id); HttpURLConnection connection=(HttpURLConnection) real_url.openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("User-Agent", user_agent); connection.setRequestProperty("Accept", "**"); connection.setRequestProperty("Content-Type", "application/octet-stream"); connection.setRequestProperty("Connection", "keep-alive"); connection.connect(); in=connection.getInputStream(); FileOutputStream out=new FileOutputStream("video.mp4"); while((len=in.read(buf))!=-1){ out.write(buf,0,len); } in.close(); out.close(); } } ``` 注意:以上代码仅供学习参考,请勿用于非法用途。
天富注册 SERVICE 致力于四大热门领域,一站式配套全面解决装修环境搭建,您只需考虑企业经营,其它的请交给我们 立即前往 Now Go → 天富登录 CASE 企业形象展示的窗口,团队能量聚积、展示才华的舞台,伙伴携手共赢、价值创造的发源地 立即前往 Now Go →