本文整理汇总了Python中splinter.Browser.find_link_by_partial_href方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.find_link_by_partial_href方法的具体用法?Python Browser.find_link_by_partial_href怎么用?Python Browser.find_link_by_partial_href使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类splinter.Browser
的用法示例。
在下文中一共展示了Browser.find_link_by_partial_href方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getRoutes
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_partial_href [as 别名]
def getRoutes(start,end):
browser = Browser(
driver_name="firefox"
)
browser.visit('https://www.hopstop.com/search?xfr=cityscape')
print(browser.url)
browser.fill('address1',str(start))
browser.fill('address2',str(end))
browser.find_by_name('get_dirs').click()
print(browser.url)
if browser.is_text_present('Did you mean?'):
print "better at least get here"
#browser.click_link_by_href("#")
for link in browser.find_link_by_href("#"):
print "Okay"
if link.visible == True:
print link.text
browser.click_link_by_text(link.text)
break
browser.click_link_by_href("#")
links = browser.find_link_by_partial_href("/station?stid")
results = []
for link in links:
results.append(link.value)
browser.quit()
return results
示例2: getRoutes
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_partial_href [as 别名]
def getRoutes(start, end):
browser = Browser(driver_name="firefox")
browser.visit("https://www.hopstop.com/search?xfr=cityscape")
print(browser.url)
browser.fill("address1", str(start))
browser.fill("address2", str(end))
browser.find_by_name("get_dirs").click()
print(browser.url)
if browser.is_text_present("Did you mean?"):
browser.click_link_by_href("#")
if browser.is_text_present("Did you mean?"):
browser.click_link_by_href("#")
browser.click_link_by_href("#")
links = browser.find_link_by_partial_href("/station?stid")
results = []
for link in links:
results.append(link.value)
return results
示例3: query_iPfam
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_partial_href [as 别名]
def query_iPfam( pdb_structures_query ):
#
# open browser
#
br = Browser()
url = 'http://www.ipfam.org/search/keyword'
br.visit(url)
#
# Search pdb structures vs. interactions
#
# make a search qeury with all the pdb structures
br.find_by_css("#keywords")[0].fill(pdb_structures_query)
br.find_by_css("input.button").click()
# all structure interactions
br.find_by_css(".lozenge > ul:nth-child(2) > li:nth-child(3) > input:nth-child(1)").click()
# all ligand interactions
# ...
# click "show all"
br.find_by_css("input.button:nth-child(3)").click()
# show 100 entries
br.find_by_css("#pdb_matches_table_length > label:nth-child(1) > select:nth-child(1)").first.select("-1")
# grab all structure's and their interactions links
count = 0
pdb_to_url = []
while True:
count += 1
try:
pdb_id = br.find_by_css("#pdb_matches_table > tbody:nth-child(2) > tr:nth-child("+str(count)+") > td:nth-child(1) > a:nth-child(1)").first.text
pdb_url = br.find_by_css("#pdb_matches_table > tbody:nth-child(2) > tr:nth-child("+str(count)+") > td:nth-child(1) > a:nth-child(1)").first['href']
pdb_to_url.append((pdb_id,pdb_url))
except exceptions.ElementDoesNotExist:
break
#
# obtain interactions per pdb
#
print "obtaining interactions for each pdb structure..."
pdb_to_interactions = {}
interaction_to_url = {}
for pdb, url in pdb_to_url:
print "pdb structure: "+pdb
br.visit(url)
interaction_status = br.find_by_css("div.lozenge:nth-child(1) > dl:nth-child(3) > dd:nth-child(2) > p:nth-child(1) > label:nth-child(2)").first.text
n_family_interactions = int(interaction_status.replace("Family (","").replace(")",""))
if n_family_interactions > 0:
print "\t\t"+str(n_family_interactions)+" interactions found"
br.find_by_value("fam_int").first.click() # click family interactions
family_interactions = br.find_link_by_partial_href("/fam_int/") # @todo: test if this is a correct matcher
for interaction in family_interactions:
interaction_url = interaction['href']
a, b = interaction_url.split("/fam_int/")
a_pfam_id = a.split("/family/")[1]
b_pfam_id = b.split("/sequence")[0]
interaction_neat = (a_pfam_id,b_pfam_id)
print "\t\t\titeraction: "+interaction_neat[0]+"-to-"+interaction_neat[1]+" url: "+interaction['href'] # e.g. RVP-to-RVP
interaction_to_url[interaction_neat] = interaction['href']
if pdb_to_interactions.has_key(pdb):
pdb_to_interactions[pdb].append(interaction_neat)
else:
pdb_to_interactions[pdb] = [interaction_neat]
else:
print "\t\t"+str(n_family_interactions)+" interactions found"
pdb_to_interactions[pdb] = []
# # save interactions data
# pickle.dump( pdb_to_interactions, open( "./data/pdb_to_interactions.p", "wb" ) )
# pickle.dump( interaction_to_url, open( "./data/interaction_to_url.p", "wb" ) )
#.........这里部分代码省略.........
示例4: Institution
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_partial_href [as 别名]
browser.find_by_name('addScenario').first.click()
browser.fill('scName', countryTypeList[conIndex]+typeaName+igType)
browser.type('scEffDate', '\b\b\b\b\b\b\b\b\b\b')
browser.type('scEffDate', '2015-10-31')
browser.find_by_name('update').first.click()
browser.find_link_by_text('Obligor').first.click()
# choose the companyType type
element = browser.find_by_name('companyType').first
element.select(str(cType))
browser.fill('obligorName', companyName)
browser.find_by_name('ObligorSearch').first.click()
browser.find_link_by_partial_href('javascript:refPortResult')[0].click()
# select "B-III counterpaty type" to be "corporate"
element = browser.find_by_name('counterPartyType').first
element.select('1')
# select "Classification re Asset Value Correlation" to be "Non-Financial Institution (N)"
element = browser.find_by_name('avc').first
element.select('4')
# select proper IG according to the IG type
if igType == 'orig':
pass
else:
element = browser.find_by_name('obligorIgCode').first
# eleVal = element.find_element_by_xpath("//option[@selected='selected']").first.value
eleVal = element.find_by_xpath('option[@selected="selected"]').first.value
示例5: bundle
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_partial_href [as 别名]
def bundle(argv):
username = ""
password = ""
all = False
overwrite = False
skip = False
try:
opts, args = getopt.getopt(argv, "hu:p:aso", ["username=", "password="] )
except getopt.GetoptError:
print_help()
exit(2)
for opt, arg in opts:
if opt == "-h":
print_help()
exit()
elif opt == "-a":
download_all_warning()
all = True
elif opt == "-o":
overwrite = True
elif opt == "-s":
skip = True
elif opt in ("-u", "--username"):
username = arg
elif opt in ("-p", "--password"):
password = arg
del argv, args, opts
if not username:
username = input("Username (email): ")
if not username:
print("Empty, exiting.")
exit(2)
if not password:
password = input("Password: ")
if not password:
print("Empty, exiting.")
exit(2)
browser = Browser()
print("Logging in...")
browser.visit('https://bundleofholding.com/user/login')
browser.fill('users_email', username)
browser.fill('password', password)
browser.find_by_name('submit').click()
if (len(browser.find_by_css("div.logged-in")) > 0):
#if browser.is_text_present("Wizard's Cabinet"):
print("Getting lists...")
browser.visit('https://bundleofholding.com/download/list')
else:
print("Failed to log in.")
if (input("Quit browser? */n ") != "n"):
browser.quit()
exit()
bListBox = browser.find_by_id('overview')
bListList = bListBox.find_by_tag('a')
bundles = []
for e in bListList:
bundles.append( (e.value, e['href']) )
del bListBox, bListList
bundle_count = len(bundles)
item = 0
vault = {}
for b in bundles:
item += 1
print("\tFile list {0} of {1}.".format(item, bundle_count))
vault[b[0]] = []
browser.visit(b[1])
bLinks = browser.find_link_by_partial_href('file_id')
# todo: get file list with file sizes if possible
# problem: not all pages have "core-bundle" element; older ones are uglier
# xpath span/a?
for e in bLinks:
vault[b[0]].append( (e.value, e['href']) )
del item, bLinks
print("\n\n")
# Chose to make command line parameter only to help reinforce FAQ.
# if not all:
# download_all_warning()
#
# totalfiles = 0
# for bundle, files in vault.items():
# totalfiles += len(files)
#
# if (input("There are {0} bundles with a total of {1} files. Download all? y/* ".format(len(vault), totalfiles) ) == "y"):
# all = True
# del totalfiles
rx = re.compile("[^\w _()'-]+")
cookies = browser.cookies.all()
currentBundle = 1
for bundle, files in vault.items():
length = len(files)
#.........这里部分代码省略.........
示例6: range
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_partial_href [as 别名]
element = browser.find_by_name('avc').first
element.select('4')
browser.fill('sic', '7759')
browser.fill('totalSale', '10')
igArray = ['99','98','95','90','87','85','83','80','77','75','73','70','65','60','40','30']
for x in range(16):
element = browser.find_by_name('obligorIgCode').first
element.select(igArray[x])
browser.find_by_name('UpdateButton').first.click()
pdData()
browser.driver.save_screenshot(typeaName + countryList[conIndex] + '_' + igArray[x] +'.png')
browser.find_link_by_partial_href('/CNETCORP/cpmScenarios.do').first.click()
else:
# create the new scenario
if cType == 0:
typeaName = 'Existing_Scotia_Public_'
elif cType == 1:
typeaName = 'Existing_Scotia_Private_'
else:
typeaName = 'Non_Scotia_Public_'
browser.find_by_name('addScenario').first.click()
browser.fill('scName', typeaName + countryList[conIndex])
browser.type('scEffDate', '\b\b\b\b\b\b\b\b\b\b')
browser.type('scEffDate', '2014-10-31')
browser.find_by_name('update').first.click()
示例7: line_login
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_partial_href [as 别名]
def line_login(browser, user_name, password, code):
"""
lineに自動ログインして、パラメータのカードコードを入力し、チャージする。
チャージした結果を返す。
:param browser:ブラウザインスタンス
:param user_name:ログインユーザネーム
:param password:ログインパスワード
:param code:ギフトカードコード
:return:チャージ結果
"""
# ログインページを開く
browser = Browser('firefox')
url = 'https://store.line.me/home/'
browser.visit(url)
# ログインする
login_submit = browser.find_link_by_partial_href('login')
if login_submit:
login_submit.click()
else:
html_code = browser.html
return {
'code': 4,
'message': "サイト上に問題が発生しました。(サイトがアクセスできない、またはネットが遅すぎる可能性があります。)",
'htmlcode': html_code
}
username_input_field = browser.find_by_id('id')
password_input_field = browser.find_by_id('passwd')
login_submit = browser.find_by_value('Login')
if username_input_field and password_input_field and login_submit:
username_input_field.fill(user_name)
password_input_field.fill(password)
login_submit.click()
else:
html_code = browser.html
return {
'code': 4,
'message': "サイト上に問題が発生しました。(サイトがアクセスできない、またはネットが遅すぎる可能性があります。)",
'htmlcode': html_code
}
# ログイン画像認識があるかどうかチェックする
#captcha_image_field = browser.find_by_css('img.FnCaptchaImg')
#メールアドレスまたパスワードをチェックする
login_alert_field = browser.find_by_css('p.mdMN02Txt')
if browser.is_element_present_by_css('p.mdMN02Txt'):
result = login_alert_field.value
if result.find(unicode('The password you have entered is invalid, or you have not registered your email address with LINE.')) != -1:
html_code = browser.html
return {
'code': 2,
'message': 'メールアドレスまたはパスワードが正しくありません。',
'htmlcode': html_code
}
# チャージ画面に移動する
browser.find_by_text('Charge').click()
browser.windows.current = browser.windows[1]
browser.find_by_id('70002').click()
browser.execute_script("charge(this); return false;")
# チャージする
code_input_field = browser.find_by_id('FnSerialNumber')
code_input_field.fill(code)
time.sleep(9000)
browser.execute_script("javascript:doCharge(this);return false;")
result = browser.find_by_css('p.mdLYR11Txt01').value
browser.quit()
return result
示例8: range
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_partial_href [as 别名]
element = browser.find_by_name('avc').first
element.select('4')
browser.fill('sic', '7759')
browser.fill('totalSale', '10')
igArray = ['99','98','95','90','87','85','83','80','77','75','73','70','65','60','40','30']
for x in range(16):
element = browser.find_by_name('obligorIgCode').first
element.select(igArray[x])
browser.find_by_name('UpdateButton').first.click()
browser.driver.save_screenshot(typeaName + countryList[conIndex] + '_' + igArray[x] +'.png')
browser.find_link_by_partial_href('/CNETCORP/cpmScenarios.do').first.click()
else:
# create the new scenario
if cType == 0:
typeaName = 'Existing_Scotia_Public_'
elif cType == 1:
typeaName = 'Existing_Scotia_Private_'
else:
typeaName = 'Non_Scotia_Public_'
browser.find_by_name('addScenario').first.click()
browser.fill('scName', typeaName + countryList[conIndex])
browser.type('scEffDate', '\b\b\b\b\b\b\b\b\b\b')
browser.type('scEffDate', '2014-10-31')
browser.find_by_name('update').first.click()