本文整理汇总了Python中mechanize.Browser.form[USER_FIELD]方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.form[USER_FIELD]方法的具体用法?Python Browser.form[USER_FIELD]怎么用?Python Browser.form[USER_FIELD]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mechanize.Browser
的用法示例。
在下文中一共展示了Browser.form[USER_FIELD]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_balance
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form[USER_FIELD] [as 别名]
def get_balance( username, password ):
balance = 0.0
browser = Browser()
try:
browser.open( URL_PATH )
except:
return balance
browser.select_form( nr=0 )
browser.form[USER_FIELD] = username
browser.form[PASS_FIELD] = password
browser.submit()
response = browser.response()
html = response.read()
browser.close()
balance_string = html_filter( html )
result = get_float( balance_string )
return result
示例2: Browser
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form[USER_FIELD] [as 别名]
from mechanize import Browser
import re
URL_PATH = 'https://ss.zadarma.com/'
USER_FIELD = 'email'
PASS_FIELD = 'password'
out_balance = 0.0
browser = Browser()
browser.open( URL_PATH )
browser.select_form( nr=0 )
browser.form[USER_FIELD] = in_username
browser.form[PASS_FIELD] = in_password
browser.submit()
browser.open( URL_PATH )
response = browser.response()
html = response.read()
browser.close()
f1 = re.search( r'>\$(.*)</a></span>', html )
if f1 is not None:
balance_string = f1.groups()[0]
print(balance_string)
out_balance = float( balance_string )