示例#1
0
文件: boxapi.py 项目: skarone/PipeL
    def _automate1(self, url, login, password):
        browser = get_browser(True)
        response = browser.open(url)
        request_token = self._get_request_token(response.read())

        browser.select_form(name="login_form1")
        browser["login"] = login
        browser["password"] = password

        # add an field which is supposed to be added by javascript
        browser.form.new_control("text", "request_token", {"value": ""})
        browser.form.fixup()
        browser["request_token"] = request_token

        response = browser.submit()
        if not browser.viewing_html():
            raise StatusError("something is wrong when browsing HTML")
示例#2
0
文件: boxapi.py 项目: mbarkhau/pybox
    def _automate1(self, url, login, password):
        browser = get_browser(True)
        response = browser.open(url)
        request_token = self._get_request_token(response.read())

        browser.select_form(name='login_form1')
        browser['login'] = login
        browser['password'] = password

        # add an field which is supposed to be added by javascript
        browser.form.new_control('text', 'request_token', {'value': ''})
        browser.form.fixup()
        browser['request_token'] = request_token

        response = browser.submit()
        if not browser.viewing_html():
            raise StatusError("something is wrong when browsing HTML")
示例#3
0
文件: boxapi.py 项目: enquora/pybox
    def _automate(cls, url, login, password):
        browser = get_browser(True)
        browser.open(url)  # suppress output?

        browser.select_form(name='login_form')
        browser['login'] = login
        browser['password'] = password

        browser.submit()
        if not browser.viewing_html():
            raise StatusError("something is wrong when browsing HTML")

        browser.select_form(name='consent_form')

        response = browser.submit()
        if not browser.viewing_html():
            raise StatusError("something is wrong when browsing HTML")

        url = response.geturl()
        import urlparse
        parsed = urlparse.parse_qs(urlparse.urlparse(url).query)
        return parsed['code'][0], parsed['state'][0]
示例#4
0
def test_get_browser():
    browser = get_browser()
    browser.open("http://www.yahoo.com")
    assert browser.viewing_html()