PyQt Qwizardpage : Cut up url after Question mark letter, and add groupbox to each found
<p>This is a double question</p>

<p>Questions</p>

<p><s>1) split url after question marks</s></p>

<p>2) when split up, count how many questions marks , and add a groupbox to each found </p>

<p>I making a Qwizardpage which have two pages.</p>

<p>PyQt4 Qwizardpage app info.</p>

<p>On page one i have a textboxEdit where i fill in a url.</p>

<p>Lets use this example url</p>

<p><code>url2 ="http://example.com/over/example?sender=senderexample&amp;password=passwxample&amp;recipients=recipientsexample&amp;sId=idexample&amp;content=contentexample"</code></p>

<p>On page 2 i wanna count in the url, how many question marks there is in the url, and add a groupbox to each question marks found. 
This is cause i wanna work with many urls.</p>

<p>so the output will be displayed like this, so i can use it for each groupbox.</p>

<pre><code>senderexample=and a groupbox
passwxample=and groupbox
recipientsexample=and groupbox
idexample=and a groupbox
contentexample=and a groupbox
</code></pre>

<p>here is the PyQt4 Qwizardpage code</p>

<pre><code>from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig,    _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_Wizard(object):
    def setupUi(self, Wizard):
        Wizard.setObjectName(_fromUtf8("Wizard"))
        Wizard.resize(523, 386)
        Wizard.setWizardStyle(QtGui.QWizard.AeroStyle)
        Wizard.setOptions(QtGui.QWizard.HaveHelpButton)
        Wizard.setTitleFormat(QtCore.Qt.AutoText)
        self.wizardPage1 = QtGui.QWizardPage()
        self.wizardPage1.setObjectName(_fromUtf8("wizardPage1"))
        self.textEditsms = QtGui.QTextEdit(self.wizardPage1)
        self.textEditsms.setGeometry(QtCore.QRect(70, 90, 391, 231))
        self.textEditsms.setObjectName(_fromUtf8("textEditsms"))
        self.textEditprovider = QtGui.QTextEdit(self.wizardPage1)
        self.textEditprovider.setGeometry(QtCore.QRect(70, 30, 391, 31))
        self.textEditprovider.setObjectName(_fromUtf8("textEditprovider"))
        self.label = QtGui.QLabel(self.wizardPage1)
        self.label.setGeometry(QtCore.QRect(200, 0, 101, 31))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label.setFont(font)
        self.label.setObjectName(_fromUtf8("label"))
        self.label_2 = QtGui.QLabel(self.wizardPage1)
        self.label_2.setGeometry(QtCore.QRect(220, 70, 61, 21))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_2.setFont(font)
        self.label_2.setObjectName(_fromUtf8("label_2"))
        Wizard.addPage(self.wizardPage1)
        self.wizardPage2 = QtGui.QWizardPage()
        self.wizardPage2.setObjectName(_fromUtf8("wizardPage2"))
        Wizard.addPage(self.wizardPage2)

        self.retranslateUi(Wizard)
        QtCore.QMetaObject.connectSlotsByName(Wizard)

    def retranslateUi(self, Wizard):
        Wizard.setWindowTitle(_translate("Wizard", "Wizard", None))
        Wizard.setWhatsThis(_translate("Wizard", "&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;", None))
        self.label.setText(_translate("Wizard", "Provider name", None))
        self.label_2.setText(_translate("Wizard", "Sms Url:", None))


if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    Wizard = QtGui.QWizard()
    ui = Ui_Wizard()
    ui.setupUi(Wizard)
    Wizard.show()
    sys.exit(app.exec_())
</code></pre>

<p>Now i have tried to split url up in different ways but none did output correct.
i tried with urlparse, re.split and also 
<a href="https://docs.python.org/2/library/urlparse.html#results-of-urlparse-and-urlsplit" rel="nofollow">urlsplit()</a></p>

<pre><code>from urlparse import parse_qs, urlparse, parse_qsl, urlsplit
import re

url2 ="http://example.com/over/example?sender=senderexample&amp;password=passwxample&amp;recipients=recipientsexample&amp;sId=idexample&amp;content=contentexample"

print parse_qs(urlparse(url2).query, 1)
print dict(parse_qsl(url2))
bob = re.split('[?.]', url2)
print bob

text = url2
dup = filter(None, re.split("[,=?:]+", text))
print dup
print url2.rsplit('?')
</code></pre>

<p>output</p>

<pre><code>{'content': ['contentexample'], 'password': ['passwxample'], 'sender':  ['senderexample'], 'recipients': ['recipientsexample'], 'sId': ['idexample']}
{'content': 'contentexample', 'password': 'passwxample', 'http://example.com/over/example?sender': 'senderexample', 'recipients': 'recipientsexample', 'sId': 'idexample'}
['http://example', 'com/over/example', 'sender=senderexample&amp;password=passwxample&amp;recipients=recipientsexample&amp;sId=idexample&amp;content=contentexample']
['http', '//example.com/over/example', 'sender', 'senderexample&amp;password', 'passwxample&amp;recipients', 'recipientsexample&amp;sId', 'idexample&amp;content', 'contentexample']
['http://example.com/over/example', 'sender=senderexample&amp;password=passwxample&amp;recipients=recipientsexample&amp;sId=idexample&amp;content=contentexample']
</code></pre>

<p>None have the right order or desired output.</p>

<p>Update !
added answer one by @Mr. eXoDia</p>

<p>okay so what i want is </p>

<pre><code>url ="http://example.com/over/example?   sender=senderexample&amp;password=passwxample&amp;recipients=recipientsexample&amp;sId=idexample&amp;content=contentexample"

for key_value in url.split("?")[1].split("&amp;"):
    tsplit = key_value.split("=")
    key = tsplit[0]
    value = tsplit[1]
    print (value)`
</code></pre>

<p>output</p>

<pre><code>senderexample
passwxample
recipientsexample
idexample
contentexample
</code></pre>

<p>You can use some string splitting in your case:</p>

<pre><code>url ="http://example.com/over/example?sender=senderexample&amp;password=passwxample&amp;recipients=recipientsexample&amp;sId=idexample&amp;content=contentexample"

for key_value in url.split("?")[1].split("&amp;"):
    tsplit = key_value.split("=")
    key = tsplit[0]
    value = tsplit[1]
    print "key: \"%s\", value: \"%s\"" % (key, value)
</code></pre>

<p>This will output:</p>

<pre><code>key: "sender", value: "senderexample"
key: "password", value: "passwxample"
key: "recipients", value: "recipientsexample"
key: "sId", value: "idexample"
key: "content", value: "contentexample"
</code></pre>

<p>Basically you first split over the initial separator (?), take the right part and split that over the separator for key value pairs (&amp;). These give you strings separated by (=) on which you split the key value pairs.</p>

python split pyqt4 groupbox