您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍python如何爬取影视网站下载链接,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
import requests,re from requests.cookies import RequestsCookieJar from fake_useragent import UserAgent import os,pickle,threading,time import concurrent.futures from goto import with_goto
def get_content_url_name(url): send_headers = { "User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "zh-CN,zh;q=0.8" } cookie_jar = RequestsCookieJar() cookie_jar.set("mttp", "9740fe449238", domain="www.yikedy.co") response=requests.get(url,send_headers,cookies=cookie_jar) response.encoding='utf-8' content=response.text reg=re.compile(r'<a href="(.*?)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="thumbnail-img" title="(.*?)"') url_name_list=reg.findall(content) return url_name_list def get_content(url): send_headers = { "User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "zh-CN,zh;q=0.8" } cookie_jar = RequestsCookieJar() cookie_jar.set("mttp", "9740fe449238", domain="www.yikedy.co") response=requests.get(url,send_headers,cookies=cookie_jar) response.encoding='utf-8' return response.text def search_durl(url): content=get_content(url) reg=re.compile(r"{'\\x64\\x65\\x63\\x72\\x69\\x70\\x74\\x50\\x61\\x72\\x61\\x6d':'(.*?)'}") index=reg.findall(content)[0] download_url=url[:-5]+r'/downloadList?decriptParam='+index content=get_content(download_url) reg1=re.compile(r'title=".*?" href="(.*?)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ') download_list=reg1.findall(content) return download_list def get_page(url): send_headers = { "User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "zh-CN,zh;q=0.8" } cookie_jar = RequestsCookieJar() cookie_jar.set("mttp", "9740fe449238", domain="www.yikedy.co") response=requests.get(url,send_headers,cookies=cookie_jar) response.encoding='utf-8' content=response.text reg=re.compile(r'<a target="_blank" class="title" href="(.*?)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" title="(.*?)">(.*?)<\/a>') url_name_list=reg.findall(content) return url_name_list @with_goto def main(): print("=========================================================") name=input("请输入剧名(输入quit退出):") if name == "quit": exit() url="http://www.yikedy.co/search?query="+name dlist=get_page(url) print("\n") if(dlist): num=0 count=0 for i in dlist: if (name in i[1]) : print(f"{num} {i[1]}") num+=1 elif num==0 and count==len(dlist)-1: goto .end count+=1 dest=int(input("\n\n请输入剧的编号(输100跳过此次搜寻):")) if dest == 100: goto .end x=0 print("\n以下为下载链接:\n") for i in dlist: if (name in i[1]): if(x==dest): for durl in search_durl(i[0]): print(f"{durl}\n") print("\n") break x+=1 else: label .end print("没找到或不想看\n")
import requests,re from requests.cookies import RequestsCookieJar from fake_useragent import UserAgent import os,pickle,threading,time import concurrent.futures from goto import with_goto def get_content_url_name(url): send_headers = { "User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "zh-CN,zh;q=0.8" } cookie_jar = RequestsCookieJar() cookie_jar.set("mttp", "9740fe449238", domain="www.yikedy.co") response=requests.get(url,send_headers,cookies=cookie_jar) response.encoding='utf-8' content=response.text reg=re.compile(r'<a href="(.*?)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="thumbnail-img" title="(.*?)"') url_name_list=reg.findall(content) return url_name_list def get_content(url): send_headers = { "User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "zh-CN,zh;q=0.8" } cookie_jar = RequestsCookieJar() cookie_jar.set("mttp", "9740fe449238", domain="www.yikedy.co") response=requests.get(url,send_headers,cookies=cookie_jar) response.encoding='utf-8' return response.text def search_durl(url): content=get_content(url) reg=re.compile(r"{'\\x64\\x65\\x63\\x72\\x69\\x70\\x74\\x50\\x61\\x72\\x61\\x6d':'(.*?)'}") index=reg.findall(content)[0] download_url=url[:-5]+r'/downloadList?decriptParam='+index content=get_content(download_url) reg1=re.compile(r'title=".*?" href="(.*?)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ') download_list=reg1.findall(content) return download_list def get_page(url): send_headers = { "User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "zh-CN,zh;q=0.8" } cookie_jar = RequestsCookieJar() cookie_jar.set("mttp", "9740fe449238", domain="www.yikedy.co") response=requests.get(url,send_headers,cookies=cookie_jar) response.encoding='utf-8' content=response.text reg=re.compile(r'<a target="_blank" class="title" href="(.*?)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" title="(.*?)">(.*?)<\/a>') url_name_list=reg.findall(content) return url_name_list @with_goto def main(): print("=========================================================") name=input("请输入剧名(输入quit退出):") if name == "quit": exit() url="http://www.yikedy.co/search?query="+name dlist=get_page(url) print("\n") if(dlist): num=0 count=0 for i in dlist: if (name in i[1]) : print(f"{num} {i[1]}") num+=1 elif num==0 and count==len(dlist)-1: goto .end count+=1 dest=int(input("\n\n请输入剧的编号(输100跳过此次搜寻):")) if dest == 100: goto .end x=0 print("\n以下为下载链接:\n") for i in dlist: if (name in i[1]): if(x==dest): for durl in search_durl(i[0]): print(f"{durl}\n") print("\n") break x+=1 else: label .end print("没找到或不想看\n") print("本软件由CLY.所有\n\n") while(True): main()
以上是“python如何爬取影视网站下载链接”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。