python+selenium模拟浏览器登录shibboleth登录的模拟
2018-03-09 20:44
603 查看
Selenium with the headless PhantomJS webkit will be your best bet to login into Shibboleth, because it handles cookies and even Javascript for you.
Installation:
$ pip install selenium $ brew install phantomjs
from selenium import webdriver from selenium.webdriver.support.ui import Select # for <SELECT> HTML form driver = webdriver.PhantomJS() # On Windows, use: webdriver.PhantomJS('C:\phantomjs-1.9.7-windows\phantomjs.exe') # Service selection # Here I had to select my school among others driver.get("http://ent.unr-runn.fr/uPortal/") select = Select(driver.find_element_by_name('user_idp')) select.select_by_visible_text('ENSICAEN') driver.find_element_by_id('IdPList').submit() # Login page (https://cas.ensicaen.fr/cas/login?service=https%3A%2F%2Fshibboleth.ensicaen.fr%2Fidp%2FAuthn%2FRemoteUser) # Fill the login form and submit it driver.find_element_by_id('username').send_keys("myusername") driver.find_element_by_id('password').send_keys("mypassword") driver.find_element_by_id('fm1').submit() # Now connected to the home page # Click on 3 links in order to reach the page I want to scrape driver.find_element_by_id('tabLink_u1240l1s214').click() driver.find_element_by_id('formMenu:linknotes1').click() driver.find_element_by_id('_id137Pluto_108_u1240l1n228_50520_:tabledip:0:_id158Pluto_108_u1240l1n228_50520_').click() # Select and print an interesting element by its ID page = driver.find_element_by_id('_id111Pluto_108_u1240l1n228_50520_:tableel:tbody_element') print page.text
原文链接:https://stackoverflow.com/questions/16512965/logging-into-saml-shibboleth-authenticated-server-using-python
相关文章推荐
- python模拟浏览器登录淘宝抓取内容
- python 利用浏览器 Cookie 模拟登录的用户访问知乎
- python selenium模拟用户登录
- python模拟浏览器打开百度首页并登录或者点击首页新闻并保存网页
- 【Python】 Selenium 模拟浏览器 寻路
- python模拟浏览器登录
- Python模拟浏览器登录淘宝
- 浅谈python爬虫使用Selenium模拟浏览器行为
- python模拟浏览器登录人人网,并使用代理IP和发送表单数据
- 用Python模拟浏览器登录
- Python selenium模拟浏览器
- Selenium+Python对开源中国官网进行模拟登录
- 使用Python+Selenium模拟登录QQ空间
- Python selenium自动化识别验证码模拟登录操作(二)
- python爬虫:使用Selenium模拟浏览器行为
- selenium 模拟浏览器登录微博
- Python 网络爬虫---四种方法模拟浏览器登录
- 【网络爬虫】【python】网络爬虫(三):模拟登录——伪装浏览器登录爬取过程
- 使用Selenium模拟浏览器登录,并获取页面信息
- python 针对selenium+phontomjs等模拟浏览器爬虫的反爬技术点