无法使用urllib python v3.2.1将数据发布到登录表单

2024-04-25 04:51:04 发布

您现在位置:Python中文网/ 问答频道 /正文

    import urllib.parse
    import urllib.request
    import time
    def __init__(self, parent= None):

    QtGui.QWidget.__init__(self,parent)
    self.ui = Ui_MainWindow()
    self.ui.setupUi(self)
    username = 'name'

    password = 'pass'
    while True:
            try:
                page=urllib.request.urlopen('http://10.100.56.55:8090/httpclient.html','&username='+username+'@da-iict.org&password='+password+'&btnSubmit=Login')
                the_page=page.read()

我一直在努力让这段代码工作。python 2中的另一种方法工作得很好,但是在python v3.2中,我得到错误“POST data应该是字节或是可iterable number of bytes


Tags: importselfnoneuitimeparseinitrequest