ask for advice. After the code is executed, enter the name of the movie you want to download, but the get ("href") link you get cannot be downloaded. I looked at the source code tag. The HREF I got is different from the Xunlei download address of the source code. The FREF I got is the same as the getText () of the a tag (in theory, the connection should be the same as the one in the following pictures). Do you have a big answer? What"s going on?
< H2 > < / H2 >-sharprequestsbs4BeautifulSoup4,bs4pip install beautifulsoup4
from urllib.request import quote
import bs4
import requests
-sharpquoteurl
movie = input(":")
gbkmovie=movie.encode("gbk")
-sharpgbkgbkmovie
urlmovie = "http://s.ygdy8.com/plus/so.php?kwtype=0&searchtype=title&keyword="+quote(gbkmovie)
-sharpgbkurl
res =requests.get(urlmovie)
-sharp
bsmovie = bs4.BeautifulSoup(res.text,"html.parser")
-sharp
link = bsmovie.select(".co_content8 b a")
-sharp
finallink = "http://www.ygdy8.com" + link[0].get("href")
-sharp
xiazai = requests.get(finallink).content.decode("gbk")
-sharprequestscontentbytesdecodexiazai
bsxiazai = bs4.BeautifulSoup(xiazai,"html.parser")
-sharpxiazaitext
download = bsxiazai.select("table tbody tr td a")
-sharp
for x in download:
print (x.get("href"))