Result from printing (trailers)目前以下代码有效,但我不希望超链接将我带到google.com。我希望它带我到变量预告片中的链接。有人可以给我一个建议。
trailers = page_soup.findAll("a",{"class":"slate_button prevent-ad-overlay video-modal"})[0]["href"]
imdbBase = "http://www.imdb.com"
trailer = imdbBase + trailers
urlLink=" <a href=\"http://www.google.com\"> <font face=Tw Cen MT Condensed size=2 color=black>Watch Trailer</font> </a>"
trailer_lbl = self.edit_trailer
self.edit_trailer.setText(urlLink)
self.edit_trailer.setOpenExternalLinks(True)
答案 0 :(得分:0)
为了能够连接网址,您可以使用format
:
trailers = "/video/imdb/vi38776120057?playlistId=tt0111161&ref=tt_ov_vi"
imdbBase = "http://www.imdb.com"
trailer = imdbBase + trailers
urlLink=" <a href=\"{url}\"> <font face=Tw Cen MT Condensed size=2 color=black>Watch Trailer</font> </a>".format(url=trailer)
trailer_lbl = QtWidgets.QLabel()
trailer_lbl.setText(urlLink)
trailer_lbl.setOpenExternalLinks(True)