def StartBrowser(browserChoice):
"""
Based on the option selected by the user start the selenium browser.
browserChoice: browser option selected by the user.
"""
if browserChoice == 1:
print '\nLaunching Chrome'
browser = webdriver.Chrome()
elif browserChoice == 2:
print '\nLaunching Firefox/Iceweasel'
browser = webdriver.Firefox()
elif browserChoice == 3:
print '\nLaunching PhantomJS'
browser = webdriver.PhantomJS()
if SignInToService(browser):
print 'Success!\n'
MediumBot(browser)
else:
soup = BeautifulSoup(browser.page_source, "lxml")
if soup.find('div', {'class':'alert error'}):
print 'Error! Please verify your username and password.'
elif browser.title == '403: Forbidden':
print 'Medium is momentarily unavailable. Please wait a moment, then try again.'
else:
print 'Please make sure your config is set up correctly.'
browser.quit()
评论列表
文章目录