# python 24行代码简单实现通过分享链接下载无水印视频

/ 21评 / 0

1. 访问地址：https://v.douyin.com/J8cHNas/，他帮我们自动跳转到一个页面。
2. 不用管页面如何，我们可以直接打开f12看到请求，稍微看一下，会发现所有的视频信息（包含视频路径、名称、作者等等）都存储在这个请求中：https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=6841990853624433920&dytk=
3. 直接从接口获取到video的链接：https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200f4f0000brpq51lahtm68p8nvh6g&ratio=720p&line=0
4. 把链接中的playwm替换成play（去掉wm就行），就可以获得无水印的地址了，如：https://aweme.snssdk.com/aweme/v1/play/?video_id=v0200f4f0000brpq51lahtm68p8nvh6g&ratio=720p&line=0
5. 注：无水印的视频，只能在移动端播放，所以我们需要在user-agent中模拟手机端的操作。
6. 至于如何得出去掉wm就可以无水印的结论，有经验的可以尝试看抖音时抓包，可以得到他的视频链接，简单对比就可以得出结论了。

import requests
import re
import json
#获取抖音地址
url=input("请输入抖音地址\n")
userAgent = "Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Mobile Safari/537.36"
"Referer": "https://v.douyin.com/",
'User-Agent': userAgent,
}
#获取到视频id
url=r.url
id=url.split("video/")[1].split("/?")[0]
#获取到有水印视频地址
url="https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids="+id
#获取到无水印视频地址
url=url.replace("playwm","play")
#开始下载
with open(video["desc"]+".mp4", "wb") as code:
code.write(r.content)
print("下载成功")
input("按下回车退出程序")

1. skrt说道：

发布一个完整的代码吧！！@#！小白搞定不了啊

• mokevip说道：

@skrt 这就是完整代码啊，可以直接拷贝到python文件中运行的

After going over a handful of the articles on your web site, I honestly appreciate your way of writing a blog.
I bookmarked it to my bookmark website list and will be checking back in the near future.
Take a look at my web site as well and let me know what you think.

3. Harriett说道：

Your style is really unique in comparison to other people I have
read stuff from. I appreciate you for posting when you
have the opportunity, Guess I will just book mark this site.

4. Truly no matter if someone doesn’t understand then its up to
other people that they will assist, so here it happens.

6. Brenda说道：

Yes! Finally someone writes about 롤대리.

7. Generally I do not read post on blogs, however I wish to say that this write-up very forced me to try and do it!
Your writing taste has been amazed me. Thanks,
very great post.

8. Lurlene说道：

Great post.

9. Janet说道：

I am not sure where you are getting your information, but good topic.
I needs to spend some time learning more or understanding more.
Thanks for wonderful information I was looking for this info for my mission.

10. I’m really loving the theme/design of your website.
Do you ever run into any internet browser compatibility
issues? A number of my blog audience have complained about my
blog not operating correctly in Explorer but looks great in Opera.
Do you have any ideas to help fix this problem?

11. Isabella说道：

Thanks for sharing your thoughts on python. Regards

12. Car garage说道：

nice written and come with approximately all important infos.

13. Simply want to say your article is as astounding.
The clarity in your post is simply cool and i can assume you’re an expert on this subject.
updated with forthcoming post. Thanks a million and please
carry on the gratifying work.

14. If some one desires to be updated with most recent technologies after that he must be visit this web site and be up to date all the
time.

15. Good post. I certainly love this site. Continue the good work!

16. Simply desire to say your article is as astounding.
The clearness in your publish is just great and i can assume
you’re knowledgeable in this subject. Well along with your permission let me to take hold of your feed to keep up to date with impending post.
Thanks a million and please carry on the enjoyable work.

17. Run meme说道：

I do not even know how I ended up here, but I
thought this post was good. I don’t know who you
are but definitely you’re going to a famous blogger if you are not already ;
) Cheers!

18. Thanks in favor of sharing such a nice thinking, article is fastidious,
thats why i have read it completely

19. I loved as much as you will receive carried out right here.
The sketch is tasteful, your authored material stylish.
nonetheless, you command get got an impatience over that you wish be
delivering the following. unwell unquestionably come further formerly again as exactly the same nearly a lot often inside case you shield this increase.

20. Hi there, just became aware of your blog through Google, and found that it
is truly informative. I’m gonna watch out for brussels.
I’ll be grateful if you continue this in future.
Numerous people will be benefited from your writing. Cheers!

• 默认
• 护眼
• 夜晚
• Serif
• Sans