To get the URL of the "Google" logo, do:
elem = doc.findFirst("div#hplogo")
qstring = elem.attribute('style')
regexp = QRegExp("^(.*:)?url\((.*)\)")
if regexp.indexIn(qstring) > -1:
imageURL = regexp.capturedTexts()[-1]
It returns imageURL = "/images/srpr/logo1w.png"
. It's necessary to use a regexp in that case because the URL is a part of a string. To get the image and show it on a label, do:
request = QNetworkRequest(QUrl("http://www.google.com/images/srpr/logo1w.png"))
reply = view.page().networkAccessManager().get(request)
byte_array = reply.readAll()
image = QImage()
image.loadFromData(byte_array)
label = QLabel()
label.setPixmap(QPixmap(image))
label.show()