import requests
from bs4 import BeautifulSoup
from urllib.parse import quote,unquote
moives_name=input('请输入你想看的电影')
moives_name_gbk=moives_name.encode('gbk')
moives_name_quote=quote(moives_name_gbk)
res_moives=requests.get('http://s.ygdy8.com/plus/s0.php?typeid=1&keyword={}'.format(moives_name_quote))
html_moives=res_moives.text
bs_moives=BeautifulSoup(html_moives,'html.parser')
bs_moives_top=bs_moives.find('div',class_='co_content8')
bs_moive=bs_moives_top.find('a')
url_moive=bs_moive['href']
res_moive=requests.get('https://www.ygdy8.com/{}'.format(url_moive))
html_moive=res_moive.text
bs_moive=BeautifulSoup(html_moive,'html.parser')
moive_link_top=bs_moive.find(style='BORDER-BOTTOM: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-RIGHT: #cccccc 1px dotted')
moive_link=moive_link_top.find('a')
link=moive_link['href']
print(moive_link_top)
假设我搜索复仇者联盟4
想要结果:
ftp://ygdy8:ygdy8@yg45.dydytt.net:4207/阳光电影www.ygdy8.com.复仇者联盟4:终局之战.HD.720p.中英双字幕.mkv
运行结果:
ftp://ygdy8:ygdy8@yg45.dydytt.net:4207/Ñô¹âµçÓ°www.ygdy8.com.¸´³ðÕßÁªÃË4£ºÖÕ¾ÖÖ®Õ½.HD.720p.ÖÐӢ˫×ÖÄ».mkv
请问出现乱码怎么办??