Запросы в Qt являются асинхронными в отличие от запросов к библиотеке, то есть они будут выполняться, когда синхронные задачи завершены, поэтому, когда вы запрашиваете данные, запрос еще не сделан, и поэтому данные будут пустыми, и Вы предполагаете, что они синхронны, Возможное решение - использовать QEventLoop.
from PyQt5 import QtCore, QtNetwork
class ImageCode():
def __init__(self):
self.url = 'https://kyfw.12306.cn/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand'
self.userAgent = b'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
self.manager = QtNetwork.QNetworkAccessManager()
self.getCheckImage()
def getCheckImage(self):
request = QtNetwork.QNetworkRequest(QtCore.QUrl(self.url))
request.setRawHeader(b'User-Agent', self.userAgent)
reply = self.manager.get(request)
loop = QtCore.QEventLoop()
reply.finished.connect(loop.quit)
loop.exec_()
responseData = reply.readAll()
print(responseData)
if reply.error() == QtNetwork.QNetworkReply.NoError:
print('Success')
else:
print('Error')
if __name__ == '__main__':
import sys
app = QtCore.QCoreApplication(sys.argv)
o = ImageCode()
Выход:
b'{"result_message":"\xe7\x94\x9f\xe6\x88\x90\xe9\xaa\x8c\xe8\xaf\x81\xe7\xa0\x81\xe6\x88\x90\xe5\x8a\x9f","result_code":"0","image":"/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAC+ASUDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2Jyggk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hf/AK9Ubrw+LieeUXOwTKoK+XnGOnetqilKKkrMa02Mc6FkDNz/AOOf/XotdDNrei4FzkbChXZjIP41sUVwUsqwlKftIQs/V/5mzr1GuVvQyjov7xmFxgMc42f/AF6mj03YQfOz/wAB/wDr1forb6nQ9p7Xl971ZDqSa5b6BRRRXUQfAGAKAGEKMNwxDYgWCoYNLLEA/9kKCg=="}'
Success
Обновление:
from PyQt5 import QtCore, QtNetwork
class ImageCode():
def __init__(self):
self.url = 'https://kyfw.12306.cn/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand'
self.userAgent = b'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
self.manager = QtNetwork.QNetworkAccessManager()
self.getCheckImage()
def getCheckImage(self):
request = QtNetwork.QNetworkRequest(QtCore.QUrl(self.url))
request.setRawHeader(b'User-Agent', self.userAgent)
self.reply = self.manager.get(request)
self.reply.finished.connect(self.handleDone)
def handleDone(self):
responseData = self.reply.readAll()
print(responseData)
if self.reply.error() == QtNetwork.QNetworkReply.NoError:
print('Success')
else:
print('Error')
QtCore.QCoreApplication.quit()
if __name__ == '__main__':
import sys
app = QtCore.QCoreApplication(sys.argv)
o = ImageCode()
sys.exit(app.exec_())
from PyQt5 import QtCore, QtNetwork
class ImageCode():
def __init__(self):
self.url = 'https://kyfw.12306.cn/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand'
self.userAgent = b'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
self.manager = QtNetwork.QNetworkAccessManager()
self.manager.finished.connect(self.handleDone)
self.getCheckImage()
def getCheckImage(self):
request = QtNetwork.QNetworkRequest(QtCore.QUrl(self.url))
request.setRawHeader(b'User-Agent', self.userAgent)
self.reply = self.manager.get(request)
def handleDone(self):
responseData = self.reply.readAll()
print(responseData)
if self.reply.error() == QtNetwork.QNetworkReply.NoError:
print('Success')
else:
print('Error')
QtCore.QCoreApplication.quit()
if __name__ == '__main__':
import sys
app = QtCore.QCoreApplication(sys.argv)
o = ImageCode()
sys.exit(app.exec_())