本文整理汇总了Python中splinter.Browser.choose方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.choose方法的具体用法?Python Browser.choose怎么用?Python Browser.choose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类splinter.Browser
的用法示例。
在下文中一共展示了Browser.choose方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submitQueue
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
def submitQueue(NETID, PASSWORD, SECURITY_QUESTIONS):
browser = Browser()
# netid page
browser.visit("https://puaccess.princeton.edu/psp/hsprod/EMPLOYEE/HRMS/h/?tab=DEFAULT")
browser.fill('userid', NETID)
browser.find_by_value("Continue").first.click()
# password page
browser.fill('Bharosa_Password_PadDataField', PASSWORD)
browser.evaluate_script("Bharosa_Password_Pad.keyPress('ENTERKEY');")
# security question page
html = browser.html
for key in SECURITY_QUESTIONS.keys():
if key in html:
answer = SECURITY_QUESTIONS[key]
browser.fill('Bharosa_Challenge_PadDataField', answer)
browser.evaluate_script("Bharosa_Challenge_Pad.keyPress('ENTERKEY');")
time.sleep(2)
# welcome to SCORE
browser.find_link_by_text("Student Center").first.click()
# student center, start by busting out of the iframe
browser.visit("https://puaccess.princeton.edu/psc/hsprod/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.SSS_STUDENT_CENTER.GBL?PORTALPARAM_PTCNAV=HC_SSS_STUDENT_CENTER&EOPP.SCNode=HRMS&EOPP.SCPortal=EMPLOYEE&EOPP.SCName=ADMN_SCORE&EOPP.SCLabel=&EOPP.SCPTcname=ADMN_SC_SP_SCORE&FolderPath=PORTAL_ROOT_OBJECT.PORTAL_BASE_DATA.CO_NAVIGATION_COLLECTIONS.ADMN_SCORE.ADMN_S200801281459482840968047&IsFolder=false&PortalActualURL=https%3a%2f%2fpuaccess.princeton.edu%2fpsc%2fhsprod%2fEMPLOYEE%2fHRMS%2fc%2fSA_LEARNER_SERVICES.SSS_STUDENT_CENTER.GBL&PortalContentURL=https%3a%2f%2fpuaccess.princeton.edu%2fpsc%2fhsprod%2fEMPLOYEE%2fHRMS%2fc%2fSA_LEARNER_SERVICES.SSS_STUDENT_CENTER.GBL&PortalContentProvider=HRMS&PortalCRefLabel=Student%20Center&PortalRegistryName=EMPLOYEE&PortalServletURI=https%3a%2f%2fpuaccess.princeton.edu%2fpsp%2fhsprod%2f&PortalURI=https%3a%2f%2fpuaccess.princeton.edu%2fpsc%2fhsprod%2f&PortalHostNode=HRMS&NoCrumbs=yes&PortalKeyStruct=yes")
browser.select('DERIVED_SSS_SCL_SSS_MORE_ACADEMICS', "1005")
browser.find_by_id("DERIVED_SSS_SCL_SSS_GO_1").first.click()
# pick semester
browser.choose("SSR_DUMMY_RECV1$sels$0", "1")
browser.find_by_id("DERIVED_SSS_SCT_SSR_PB_GO").first.click()
# select classes to add... class should already be in queue
browser.find_by_id("DERIVED_REGFRM1_LINK_ADD_ENRL$115$").first.click()
# confirm classes
browser.find_by_id("DERIVED_REGFRM1_SSR_PB_SUBMIT").first.click()
示例2: test_add_name
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
def test_add_name(self):
driver =Browser('firefox')
#navigate to webpage
driver.visit('http://www.ranorex.com/web-testing-examples/vip/')
#enter First name
driver.find_by_xpath('//*[@id="'"FirstName"'"]').fill('Prasanth')
#Enter Last name
driver.find_by_xpath('//*[@id="'"LastName"'"]').fill('Patil')
#Selecting the category
driver.select_id('Category','Music')
driver.choose('Gender','male')
driver.find_by_xpath('//*[@id="'"Add"'"]').click()
#def test_load(self):
driver.find_by_xpath('//*[@id="'"Load"'"]').click()
#def test_save(self):
driver.find_by_xpath('//*[@id="'"Save"'"]').click()
示例3: CollaboratorTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
#.........这里部分代码省略.........
self.assertEqual(text, "Alice's node")
Graph.objects.get(name="Bob's graph").destroy()
def test_data_add_without_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
create_schema(self)
create_type(self)
add_permission(self, 'alice', CREATE_COLLAB)
add_permission(self, 'alice', DATA_VIEW)
logout(self)
signin(self, 'alice', 'alice_secret')
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
self.browser.find_by_xpath("//a[@id='dataMenu']").first.click()
self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption new']").first.click()
text = self.browser.find_by_xpath(
"//div[@class='heading']/h1").first.value
self.assertNotEqual(text.find("403"), -1)
Graph.objects.get(name="Bob's graph").destroy()
def test_data_add_with_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
create_schema(self)
create_type(self)
add_permission(self, 'alice', CREATE_COLLAB)
add_permission(self, 'alice', DATA_VIEW)
add_permission(self, 'alice', DATA_ADD)
logout(self)
signin(self, 'alice', 'alice_secret')
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
self.browser.find_by_xpath("//a[@id='dataMenu']").first.click()
self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption new']").first.click()
self.browser.find_by_xpath(
"//input[@id='id_Name']").first.fill("Alice's node")
self.browser.find_by_xpath("//input[@type='submit']").first.click()
text = self.browser.find_by_xpath("//table[@id='content_table']/tbody/tr/td")[1].value
self.assertEqual(text, "Alice's node")
Graph.objects.get(name="Bob's graph").destroy()
def test_data_delete_without_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
create_schema(self)
create_type(self)
create_data(self)
add_permission(self, 'alice', CREATE_COLLAB)
add_permission(self, 'alice', DATA_VIEW)
add_permission(self, 'alice', DATA_CHANGE)
logout(self)
signin(self, 'alice', 'alice_secret')
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
self.browser.find_by_xpath("//a[@id='dataMenu']").first.click()
self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption list']").first.click()
self.browser.find_by_xpath("//td/a[@title='Edit node']").first.click()
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a[text()='Remove']").first.click()
text = self.browser.find_by_xpath(
"//div[@class='heading']/h1").first.value
self.assertNotEqual(text.find("403"), -1)
Graph.objects.get(name="Bob's graph").destroy()
def test_data_delete_with_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
create_schema(self)
create_type(self)
create_data(self)
add_permission(self, 'alice', CREATE_COLLAB)
add_permission(self, 'alice', DATA_VIEW)
add_permission(self, 'alice', DATA_CHANGE)
add_permission(self, 'alice', DATA_DELETE)
logout(self)
signin(self, 'alice', 'alice_secret')
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
self.browser.find_by_xpath("//a[@id='dataMenu']").first.click()
self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption list']").first.click()
self.browser.find_by_xpath("//td/a[@title='Edit node']").first.click()
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a[text()='Remove']").first.click()
self.browser.choose('confirm', '1')
self.browser.find_by_xpath("//input[@type='submit']").first.click()
text = self.browser.find_by_xpath(
"//div[@id='content2']/div[@class='indent']").first.value
self.assertNotEqual(text.find('Nodes: 0'), -1)
Graph.objects.get(name="Bob's graph").destroy()
示例4: WorkerThread
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
#.........这里部分代码省略.........
self.wait_time = 2
self.browser.visit("http://sups.shirazu.ac.ir/sfxweb/Gate/Login.aspx")
self.browser.is_element_not_present_by_id("edId", self.wait_time) # wait until see the element
self.browser.find_by_id("edId").fill(username)
self.browser.find_by_id("edPass").fill(password)
self.browser.find_by_id("edWebApp").select(1)
self.browser.find_by_id("edEnter").click()
self.browser.find_by_css("ul.active:nth-child(3) > li:nth-child(2)").click()
def reserve_this(self, selected_date, selected_rest, selected_meal, foods_of_meal):
# select restaurant
rest = self.browser.find_by_id("edRestaurant")
self.browser.select("edRestaurant", selected_rest)
# select date
self.browser.is_element_not_present_by_id("edDate", self.wait_time) # wait until see the element
self.browser.select("edDate", selected_date)
# select meal
self.browser.is_element_not_present_by_id("edMeal", self.wait_time) # wait until see the element
meal = self.browser.find_by_id("edMeal")
meal.select(selected_meal)
# collect serving foods
serving_foods = []
self.browser.is_element_not_present_by_id("Food", self.wait_time) # wait until see the element
number_of_foods = len(self.browser.find_by_css("#Food li"))
for nth in range(1, number_of_foods + 1):
value = self.browser.find_by_css("#Food > li:nth-child(" + str(nth) + ") > input:nth-child(1)").value
serving_foods.append(value)
# select food and reserv
reserved = False
for food in foods_of_meal: # select food of that meal
if str(food) in serving_foods:
self.browser.choose("Food", str(food))
self.browser.find_by_id("btnBuyChip").click()
reserved = True
break
return reserved
def date_of_this_friday(self):
today = datetime.date.today()
week_day_of_today_gre = today.weekday()
week_day_of_today_per = week_day_of_today_gre + 2 if week_day_of_today_gre < 5 else week_day_of_today_gre - 5
days_to_friday = datetime.timedelta(days=6 - week_day_of_today_per)
this_friday = today + days_to_friday
return this_friday
def collect_available_days(self):
dates = self.collect_available_dates() # find the available dates
this_friday = self.date_of_this_friday()
next_saturday = this_friday + datetime.timedelta(days=1)
this_week_available_days = {}
next_week_available_days = {}
for date in dates:
year = int(date[0:4])
month = int(date[4:6])
day = int(date[6:8])
gre_date = jalali.Persian(year, month, day).gregorian_datetime()
weekday = gre_date.weekday()
day_number = weekday + 2 if weekday < 5 else weekday - 5
if gre_date > this_friday:
next_week_available_days[str(day_number)] = date
if gre_date < next_saturday:
this_week_available_days[str(day_number)] = date
return (this_week_available_days, next_week_available_days)
def collect_available_dates(self):
rest = self.browser.find_by_id("edRestaurant")
self.browser.select("edRestaurant", "8")
dates = []
number_of_dates = len(self.browser.find_by_css("#edDate >option"))
for nth in range(2, number_of_dates + 1):
value = self.browser.find_by_css("#edDate > option:nth-child(" + str(nth) + ")").value
dates.append(value)
return dates
def take_screenshot(self, username, nameOfList):
# self.browser.back()
# self.browser.find_by_css('ul.active:nth-child(3) > li:nth-child(1)').click()
self.browser.driver.save_screenshot("./screenshots/" + username + nameOfList[0:-5] + ".png")
def open_screenshot(self, username, nameOfList):
filename = os.getcwd() + "/screenshots/" + username + nameOfList[0:-5] + ".png"
if sys.platform == "win32":
os.startfile(filename)
else:
opener = "open" if sys.platform == "darwin" else "xdg-open"
subprocess.call([opener, filename])
def check_credit(self):
string_credit = self.browser.find_by_id("lblCredit")
int_credit = int(string_credit.text.replace(",", ""))
if int_credit < -1500:
return int_credit
return True
示例5: DataNodeTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
class DataNodeTestCase(LiveServerTestCase):
"""
A set of tests to test all interaction related to the creation and
deletion of nodes and relationships. Also, we test export the data in two
formats: gexf and csv.
"""
def setUp(self):
self.browser = Browser()
socket.setdefaulttimeout(30)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
def tearDown(self):
logout(self)
self.browser.quit()
@classmethod
def tearDownClass(cls):
sleep(10) # It needs some time for close the LiverServerTestCase
super(DataNodeTestCase, cls).tearDownClass()
def test_data_node_addition(self):
create_graph(self)
create_schema(self)
create_type(self)
create_data(self)
# Check the node name
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
text = self.browser.find_by_id('propertiesTitle').first.value
spin_assert(lambda: self.assertEqual(text, 'Properties'))
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a").first.click()
self.browser.choose('confirm', '1')
self.browser.find_by_value('Continue').first.click()
text = self.browser.find_by_xpath("//div[@class='indent']/div").first.value
Graph.objects.get(name="Bob's graph").destroy()
spin_assert(lambda: self.assertEqual(text, 'Nodes: 0'))
def test_data_node_addition_rel_add_del(self):
create_graph(self)
create_schema(self)
create_type(self)
create_node(self, "Bob")
create_node(self, "Alice")
# We create a allowed relation
js_code = "$('a#schema-link')[0].click();"
self.browser.execute_script(js_code)
self.browser.find_by_id('allowedRelations').first.click()
self.browser.select('source', '1')
self.browser.find_by_name('name').fill("Bob's rel")
self.browser.select('target', '1')
self.browser.find_by_id('id_description').fill("This the allowed relationship for Bob's graph")
self.browser.find_by_value('Save Type').first.click()
spin_assert(lambda: self.assertEqual(
self.browser.title, "SylvaDB - Bob's graph"))
# We create the link between the nodes
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption list']").first.click()
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
self.browser.find_by_xpath("//li[@class='token-input-input-token']/input").first.fill('Alice')
self.browser.is_element_present_by_id("id_user_wait", 5)
self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
self.browser.find_by_value("Save Bob's type").first.click()
# Delete the relationship
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
self.browser.find_by_xpath("//span[@class='all-relationships incoming-relationships i_bobs_rel1-relationships']//a[@class='delete-row initial-form floating']").first.click()
self.browser.find_by_value("Save Bob's type").first.click()
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
spin_assert(lambda: self.assertEqual(text, "0 relationships"))
Graph.objects.get(name="Bob's graph").destroy()
def test_node_type_deletion_keeping_nodes(self):
create_graph(self)
create_schema(self)
create_type(self)
# Adding relationship to the type
self.browser.find_by_id('allowedRelations').first.click()
self.browser.select('source', '1')
self.browser.find_by_name('name').fill("Bob's rel")
self.browser.select('target', '1')
self.browser.find_by_id('id_description').fill(
'The loved relationship')
self.browser.find_by_value('Save Type').first.click()
text = self.browser.find_by_xpath(
"//div[@class='form-row indent']/label").first.value
spin_assert(lambda: self.assertNotEqual(text.find("Bob's rel"), -1))
# Creating nodes
create_node(self, 'Bob')
create_node(self, 'Alice')
# Creating relationship between nodes
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption list']").first.click()
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
self.browser.find_by_xpath("//li[@class='token-input-input-token']/input").first.fill('Alice')
self.browser.is_element_present_by_id("id_user_wait", wait_time=5)
self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
self.browser.find_by_value("Save Bob's type").first.click()
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
#.........这里部分代码省略.........
示例6: SchemaTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
#.........这里部分代码省略.........
"//div[@class='content2-first']/h2").first.value
self.assertEqual(text, 'Type')
self.browser.find_by_name('name').first.fill("Bob's type")
self.browser.find_by_id('advancedModeButton').first.click()
self.browser.find_by_name('properties-0-key').first.fill('auto increment name')
self.browser.find_by_name('properties-0-display').first.check()
self.browser.find_by_name('properties-0-required').first.check()
self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Auto']/option[@value='i']").first.click()
self.browser.find_by_name('properties-0-order').first.fill('1')
self.browser.find_by_name('properties-0-description').first.fill(
"The name of this Bob's node")
self.browser.find_by_value('Save Type').first.click()
text = self.browser.find_by_id(
'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
self.assertEqual(text, "auto increment name")
def test_new_advanced_type_auto_increment_update(self):
create_graph(self)
create_schema(self)
self.browser.find_link_by_href(
'/schemas/bobs-graph/types/create/').first.click()
text = self.browser.find_by_xpath(
"//div[@class='content2-first']/h2").first.value
self.assertEqual(text, 'Type')
self.browser.find_by_name('name').first.fill("Bob's type")
self.browser.find_by_id('advancedModeButton').first.click()
self.browser.find_by_name('properties-0-key').first.fill('auto increment update')
self.browser.find_by_name('properties-0-display').first.check()
self.browser.find_by_name('properties-0-required').first.check()
self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Auto']/option[@value='o']").first.click()
self.browser.find_by_name('properties-0-order').first.fill('1')
self.browser.find_by_name('properties-0-description').first.fill(
"The name of this Bob's node")
self.browser.find_by_value('Save Type').first.click()
text = self.browser.find_by_id(
'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
self.assertEqual(text, "auto increment update")
def test_new_advanced_type_auto_user(self):
create_graph(self)
create_schema(self)
self.browser.find_link_by_href(
'/schemas/bobs-graph/types/create/').first.click()
text = self.browser.find_by_xpath(
"//div[@class='content2-first']/h2").first.value
self.assertEqual(text, 'Type')
self.browser.find_by_name('name').first.fill("Bob's type")
self.browser.find_by_id('advancedModeButton').first.click()
self.browser.find_by_name('properties-0-key').first.fill('auto user name')
self.browser.find_by_name('properties-0-display').first.check()
self.browser.find_by_name('properties-0-required').first.check()
self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Auto']/option[@value='e']").first.click()
self.browser.find_by_name('properties-0-order').first.fill('1')
self.browser.find_by_name('properties-0-description').first.fill(
"The name of this Bob's node")
self.browser.find_by_value('Save Type').first.click()
text = self.browser.find_by_id(
'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
self.assertEqual(text, "auto user name")
def test_schema_allowed_rel_addition(self):
create_graph(self)
self.assertEqual(self.browser.title, 'SylvaDB - Dashboard')
create_schema(self)
create_type(self)
self.assertEqual(self.browser.title, "SylvaDB - Bob's graph")
self.browser.find_by_id('allowedRelations').first.click()
self.browser.select('source', '1')
self.browser.find_by_name('name').fill('Bob\'s rel')
self.browser.select('target', '1')
self.browser.find_by_id('id_description').fill('This the allowed relationship for Bob\'s graph')
self.browser.find_by_value('Save Type').first.click()
self.assertEqual(self.browser.title, "SylvaDB - Bob's graph")
text = self.browser.find_by_xpath(
"//div[@class='form-row indent']/label").first.value
self.assertNotEqual(text.find('Bob\'s rel'), -1)
def test_schema_allowed_rel_addition_deletion(self):
create_graph(self)
self.assertEqual(self.browser.title, 'SylvaDB - Dashboard')
create_schema(self)
create_type(self)
self.assertEqual(self.browser.title, "SylvaDB - Bob's graph")
self.browser.find_by_id('allowedRelations').first.click()
self.browser.select('source', '1')
self.browser.find_by_name('name').fill('Bob\'s rel')
self.browser.select('target', '1')
self.browser.find_by_id('id_description').fill('This the allowed relationship for Bob\'s graph')
self.browser.find_by_value('Save Type').first.click()
self.assertEqual(self.browser.title, "SylvaDB - Bob's graph")
text = self.browser.find_by_xpath(
"//div[@class='form-row indent']/label").first.value
self.assertNotEqual(text.find('Bob\'s rel'), -1)
self.browser.find_by_xpath("//div[@class='form-row indent']/div[@class='form-row indent']/a").first.click()
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a[@class='delete']").first.click()
self.browser.choose('confirm', '1')
self.browser.find_by_value('Continue').first.click()
notExists = self.browser.is_element_not_present_by_xpath(
"//div[@class='form-row indent']/label")
self.assertEqual(notExists, True)
示例7: map
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
while True:
line = motifs.readline().strip()
if line == "":
break
if line.startswith(">") == False:
s += " ".join(x for x in map(str, line.split())) + "\n"
else:
# print "Opening browser..."
from splinter import Browser
browser = Browser()
browser.visit("http://meme.nbcr.net/meme/cgi-bin/tomtom.cgi")
# print "Filling form..."
browser.choose("motif_src", "matrix")
browser.fill("matrix_data", s)
browser.select("motif_db", 3)
browser.find_by_name("search").click()
while True:
time.sleep(4)
if browser.title.endswith("e"):
break
# print "Getting txt output..."
u = browser.url
browser.visit(u[:-10] + "tomtom.txt")
page = browser.html
browser.quit()
示例8: gerekiyor
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
from splinter import Browser
import time
# NOT-1: tarayici olarak chrome'u kullanmak isterseniz
# driver'i indirip path'inize eklemeniz gerekiyor; linki:
# http://chromedriver.storage.googleapis.com/index.html
# eger firefox kullanmak isterseniz tarayicinin yuklu olmasi yeterli
# yalniz, bir defaliga mahsus bir ayar yapmaniz gerekiyor (bkz. NOT-2)
browser = Browser('firefox')
#Secim sonuclari sayfasi
browser.visit("https://sonuc.ysk.gov.tr/module/GirisEkrani.jsf")
#Browser tavsiye ekrani
browser.find_by_name('closeMessageButton').click()
#Yerel secimler 2014
browser.choose('j_id111:secimSorgulamaForm:j_id114:secimSecmeTable:1:secimId','true')
browser.find_by_name('j_id111:secimSorgulamaForm:j_id141').first.click()
# NOT-2: Eger tarayici olarak firefox'u secti isteniz tam bu asamada
# herhangi bir ilcenin datasini manuel olarak indirmeye calisin
# karsiniza cikan pencerede her zaman kaydet kutucugunu seciniz !
for il in range(0,82):
browser.select('j_id47:j_id48:j_id88:cmbIl',str(il))
time.sleep(2) # ilcelerin dolmasini bekle
ilce_sayisi = len(browser.find_by_id("j_id47:j_id48:j_id100:cmbSecimCevresi").first.find_by_tag('option'))-1
for i in range(0,ilce_sayisi):
i = i + 1 #ilce indexi [1,ilce_sayisi] araliginda
ilceler = browser.find_by_id("j_id47:j_id48:j_id100:cmbSecimCevresi").first.find_by_tag('option')
browser.select('j_id47:j_id48:j_id100:cmbSecimCevresi',ilceler[i].value)
time.sleep(2) #lutfen bekleyinizi bekle :S
示例9: open
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
secfirst = True
for radiooption in profradiooptions:
if secfirst:
secfirst = False
else:
browser.select('selectlistLan', county)
print "Current county: " + curcounty
browser.select('selectlistKommun', municipality)
print "Current municipality: " + curmunicipality
browser.select('selectlistYrkesomrade', workarea)
print "Current workarea: " + curworkarea
browser.select('selectlistDelomrade', profession)
print "Current profession: " + curprofession
browser.find_by_name('cmdSearch').click()
browser.choose('iYrkeBenamningID', radiooption)
curdetailedprof = browser.find_by_value(radiooption).find_by_xpath('..').text
print "Current detailed profession: " + curdetailedprof
browser.find_by_name('cmdSearch').click()
# Saving current options to an external file
currentoptions = (county, municipality, workarea, profession, radiooption)
with open('options.dump', 'wb+') as dmp:
pickle.dump(currentoptions, dmp)
# Saving entries
示例10: get_flights
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import choose [as 别名]
def get_flights(origin_airport_code, destination_airport_code, departure_date_str):
browser = Browser('phantomjs')
browser.visit('https://www.southwest.com/')
booking_button = browser.find_by_id('booking-form--flight-tab')[0]
booking_button.click()
#if return_date:
# browser.choose('twoWayTrip','true')
#else:
browser.choose('twoWayTrip','false')
#departure_date_str = departure_date.strftime("%m/%d/%y")
# works better with the date selected first... no idea why.
browser.execute_script("document.getElementsByName('outboundDateString')[0].type = 'visible'")
time.sleep(2)
browser.fill('originAirport', origin_airport_code)
browser.fill('destinationAirport', destination_airport_code)
browser.execute_script("document.getElementsByName('outboundDateString')[0].type = 'visible'")
browser.fill('outboundDateString', departure_date_str)
submit_button = browser.find_by_id('jb-booking-form-submit-button')[0]
submit_button.click()
flights_DOM_table = browser.find_by_css('.bugTableRow')
flights_table = []
for flight_DOM in flights_DOM_table:
depart_time = flight_DOM.find_by_css('.depart_column .time').text
depart_time = depart_time.zfill(5)
depart_am_pm = flight_DOM.find_by_css('.depart_column .indicator').text
duration = parse_duration(flight_DOM.find_by_css('.duration').text)
depart_str = departure_date_str + ", " + depart_time + depart_am_pm
departure = datetime.datetime.strptime(depart_str, "%m/%d/%y, %I:%M%p")
arrival = departure + duration
#arrive_time = flight_DOM.find_by_css('.arrive_column .time').text
#arrive_am_pm = flight_DOM.find_by_css('.arrive_column .indicator').text
flight_nums = flight_DOM.find_by_css('.bugLinkText') # could be a few of these
f = []
for num in flight_nums:
f.append(num.text[0:-14])
routing = flight_DOM.find_by_css('.bugLinkRouting').text[0:-14]
if len(f) > 1:
routing += " - " + flight_DOM.find_by_css('.search-results--flight-stops').text
box = flight_DOM.find_by_css('.price_column')[2] # only the wanna get away
#check if sold out, unavailable or available
price = None
try:
price = box.find_by_css('label.product_price')[0].text[1:] #strips the currency symbol
except splinter.exceptions.ElementDoesNotExist:
pass
try:
price = box.find_by_css('.insufficientInventory')[0].text.strip()
except splinter.exceptions.ElementDoesNotExist:
pass
try:
price = box.find_by_css('.unqualifiedForAnyFare')[0].text.strip()
except:
pass
flight = (origin_airport_code, destination_airport_code, departure, arrival, tuple(f), routing, price)
flights_table.append(flight)
return flights_table