当前位置: 首页>>代码示例>>Python>>正文


Python robobrowser.RoboBrowser方法代码示例

本文整理汇总了Python中robobrowser.RoboBrowser方法的典型用法代码示例。如果您正苦于以下问题:Python robobrowser.RoboBrowser方法的具体用法?Python robobrowser.RoboBrowser怎么用?Python robobrowser.RoboBrowser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在robobrowser的用法示例。


在下文中一共展示了robobrowser.RoboBrowser方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_templates

# 需要导入模块: import robobrowser [as 别名]
# 或者: from robobrowser import RoboBrowser [as 别名]
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 
开发者ID:briancurt,项目名称:pixelarity-download,代码行数:18,代码来源:pixelarity-download.py

示例2: get_access_token

# 需要导入模块: import robobrowser [as 别名]
# 或者: from robobrowser import RoboBrowser [as 别名]
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 
开发者ID:philipperemy,项目名称:Deep-Learning-Tinder,代码行数:18,代码来源:tinder_token.py

示例3: get_fb_access_token

# 需要导入模块: import robobrowser [as 别名]
# 或者: from robobrowser import RoboBrowser [as 别名]
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."} 
开发者ID:fbessez,项目名称:Tinder,代码行数:23,代码来源:fb_auth_token.py

示例4: populate_data

# 需要导入模块: import robobrowser [as 别名]
# 或者: from robobrowser import RoboBrowser [as 别名]
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) 
开发者ID:metakgp,项目名称:wimp,代码行数:32,代码来源:main.py

示例5: open_cart_web

# 需要导入模块: import robobrowser [as 别名]
# 或者: from robobrowser import RoboBrowser [as 别名]
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/') 
开发者ID:nikan1996,项目名称:nike_purchase_system,代码行数:5,代码来源:open_web_with_cookies.py

示例6: __init__

# 需要导入模块: import robobrowser [as 别名]
# 或者: from robobrowser import RoboBrowser [as 别名]
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) 
开发者ID:Gaarv,项目名称:kadenze-dl,代码行数:7,代码来源:kadenzeclient.py

示例7: mainScript

# 需要导入模块: import robobrowser [as 别名]
# 或者: from robobrowser import RoboBrowser [as 别名]
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 
开发者ID:mswhirl,项目名称:autoflashgui,代码行数:59,代码来源:libautoflashgui.py

示例8: main

# 需要导入模块: import robobrowser [as 别名]
# 或者: from robobrowser import RoboBrowser [as 别名]
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!") 
开发者ID:briancurt,项目名称:pixelarity-download,代码行数:49,代码来源:pixelarity-download.py


注:本文中的robobrowser.RoboBrowser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。