Python robobrowser.RoboBrowser() Examples

The following are 8 code examples of robobrowser.RoboBrowser(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module robobrowser , or try the search function .
Example #1
Source File: pixelarity-download.py    From pixelarity-download with MIT License 6 votes vote down vote up
def get_templates():
    """Return all Pixelarity templates in an array."""
    templates = []

    browser = RoboBrowser(parser='html.parser')
    browser.open("https://pixelarity.com/")
    r = browser.parsed()
    soup = BeautifulSoup(str(r[0]), features="html.parser")
    t = soup.find("section").find_all("article")

    for index in range(len(t)):
        templates.append(t[index].a.get("href").replace("/", ""))
    templates = [item.lower() for item in templates]
    templates = [item.replace(" ", "") for item in templates]

    return templates 
Example #2
Source File: tinder_token.py    From Deep-Learning-Tinder with MIT License 6 votes vote down vote up
def get_access_token(email, password):
    s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
    s.open(FB_AUTH)
    f = s.get_form()
    f["pass"] = password
    f["email"] = email
    s.submit_form(f)
    f = s.get_form()
    try:
        s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
        # print(s.response.content.decode())
        access_token = re.search(r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
    except requests.exceptions.InvalidSchema as browserAddress:
        # print(type(browserAddress))
        access_token = re.search(r"access_token=([\w\d]+)", str(browserAddress)).groups()[0]
    return access_token 
Example #3
Source File: fb_auth_token.py    From Tinder with MIT License 5 votes vote down vote up
def get_fb_access_token(email, password):
    s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
    s.open(FB_AUTH)
    f = s.get_form()
    f["pass"] = password
    f["email"] = email
    s.submit_form(f)
    f = s.get_form()
    try:
        s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
        access_token = re.search(
            r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
        return access_token
    except requests.exceptions.InvalidSchema as browserAddress:
        access_token = re.search(
            r"access_token=([\w\d]+)",str(browserAddress)).groups()[0]
        return access_token
    except Exception as ex:
        print("access token could not be retrieved. Check your username and password.")
        print("Official error: %s" % ex)
        return {"error": "access token could not be retrieved. Check your username and password."} 
Example #4
Source File: main.py    From wimp with GNU General Public License v3.0 5 votes vote down vote up
def populate_data(specific_dep=None):
    if not os.getenv('JSESSIONID'):
        print("ERROR: Please set environment variable JSESSIONID!")
        sys.exit(1)

    cookie = {
        "JSESSIONID": os.getenv('JSESSIONID')
    }

    # Browser
    global br
    br = RoboBrowser(history=True,
                     user_agent='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0',
                     parser='lxml'
                     )

    # Update cookie
    br.session.cookies.update(cookie)

    with open(os.path.join(path, 'data/deps.4')) as f:
        deps = f.read().split('\n')
    # parse_html('EC')
    if specific_dep is None:
        for dep in deps:
            parse_html(dep)
    else:
        parse_html(specific_dep)

    with open(os.path.join(path, 'data/data.json'), 'w') as f:
        json.dump(profs_dict, f) 
Example #5
Source File: open_web_with_cookies.py    From nike_purchase_system with GNU General Public License v3.0 5 votes vote down vote up
def open_cart_web(session):
    browser = RoboBrowser(session)
    browser.open('https://secure-store.nike.com/cn/checkout/html/cart.jsp?country=CN&country=CN&l=cart&site=nikestore&returnURL=http://www.nike.com/cn/zh_cn/') 
Example #6
Source File: kadenzeclient.py    From kadenze-dl with MIT License 5 votes vote down vote up
def __init__(self):
        self.conf = Settings()
        self.base_url = "https://www.kadenze.com"
        self.session = Session()
        self.browser = RoboBrowser(history=True, session=self.session, parser="lxml", allow_redirects=True) 
Example #7
Source File: libautoflashgui.py    From autoflashgui with GNU General Public License v3.0 4 votes vote down vote up
def mainScript(host, username, password, flashFirmware, upgradeFilename, flashSleepDelay, activeMethod, activeCommand, splitCommand, ddnsService, connectRetryDelay, interCommandDelay):
    br = RoboBrowser(history=True, parser="html.parser")

    success = False
    if flashFirmware:
        print(_("Authenticating"))
        srp6authenticate(br, host, username, password)
        br.open('http://' + host)
        token = br.find(lambda tag: tag.has_attr('name') and tag['name'] == 'CSRFtoken')['content']
        print(_("Sending flash command to modem"))
        filedata = {'CSRFtoken': token, 'upgradefile': (upgradeFilename, open(upgradeFilename, 'rb'))}
        r = br.session.post('http://' + host + '/modals/gateway-modal.lp?action=upgradefw', files=filedata)
        br._update_state(r)
        print(r.text)
        if r.text == '{ "success":"true" }':
            print(_("Modem reports flashing commenced successfully"))
            success = True
            print(_("Waiting for reboot... Sleeping for %s s") % (flashSleepDelay))
            time.sleep(int(flashSleepDelay))
    else:
        success = True

    if success:
        backUp = False
        attempt = 0
        while not backUp:
            attempt += 1
            print(_("Connect attempt %i") % (attempt))
            try:
                br.open('http://' + host)
                print (br.response)
                if br.response.ok:
                    backUp = True
            except Exception:
                print(_('Failed to connect, attempt %i.  Retrying') % (attempt))
                time.sleep(int(connectRetryDelay))
                pass

        print(_("Modem up"))

    print(_("Authenticating"))
    srp6authenticate(br, host, username, password)
    br.open('http://' + host)
    token = br.find(lambda tag: tag.has_attr('name') and tag['name'] == 'CSRFtoken')['content']

    if not splitCommand:
        runCommand(br, host, token, activeMethod, activeCommand, ddnsService)
    else:
        print(_("Splitting command up using semicolons"))
        for subCommand in [s for s in activeCommand.split(';') if len(s) > 0]:
            runCommand(br, host, token, activeMethod, subCommand, ddnsService)
            print(_("Sleeping..."))
            time.sleep(int(interCommandDelay))

    result = _("Please try a ssh connection now to ") + host + _(" with username root and password root (change password immediately with passwd!)  Rebooting your modem now is recommended to stop any services that have been disabled.")
    print(result)
    return result 
Example #8
Source File: pixelarity-download.py    From pixelarity-download with MIT License 4 votes vote down vote up
def main():

    parser = ArgumentParser(description="Pixelarity template downloader")
    parser.add_argument("email")
    parser.add_argument("password")
    parser.add_argument(
        "-f",
        "--force",
        help="Force redownload of all themes. Supply `True` or `False`",
        action="store_true",
        required=False,
    )
    parser.add_argument(
        "-p",
        "--psd",
        help="Download PSD themes too",
        action="store_true",
        required=False,
    )
    parser.add_argument(
        "-x",
        "--extract",
        help="Extract templates zipfiles",
        action="store_true",
        required=False,
    )
    args = parser.parse_args()

    browser = RoboBrowser(parser='html.parser')
    templates = get_templates()

    browser.open("https://pixelarity.com/login")

    login_form = browser.get_form(id="ajaxForm1")

    login_form["email"].value = args.email
    login_form["password"].value = args.password

    browser.submit_form(login_form)

    for template in templates:
        for template_type in ["html", "psd"]:
            download_template(template, template_type, args.force, browser)
            if args.extract:
                extract_template(template, template_type, args.force)

    print("[+] All themes downloaded successfully!")