我正在尝试从我大学的一个网站上抓取数据,该网站使用 Shibboleth 作为一种身份验证/保护形式。但是,我很难确定通过它并到达我希望抓取的页面的最佳方式。我有有效的凭据,可以用来登录。有人对如何完成这项任务有任何建议吗?
5 回答
I have been working on scripting Shibbolized login with success ( in my case, to monitor the health of both the Shibboleth IdP and the applications it protects).
I am using Python's urllib
module and their classes to handle the redirect following and cookie passing (for Shibboleth) and login form posting. After a little bit of tinkering urllib gets you most of the way to success with Shibbolized login. You could use this approach to handle the initial login to the Shibbolized website and then handle the scraping with a straight forward use of Python's urllib
.
我相信ECP配置文件旨在通过非浏览器客户端(即命令行)访问 Shibboleth 受保护的资源
尝试我在上面链接的 Shibboleth wiki 页面上提供的示例客户端之一
你也可以试试Apache JMeter,只记录你的动作,编写一些脚本(好吧,就 shibboleth 而言,这并不容易),你可以自动访问这个页面。
[编辑 - 更好的解决方案] 我相信在 Shibboleth 文档页面上是Grinder(另一种负载测试工具)的脚本。这个测试计划实际上应该很容易修改并用于您的目的的 Python (ok Jython) 脚本
您可以使用 Mechanize 提交表单并登录网站:http ://wwwsearch.sourceforge.net/mechanize/
回复很晚,但是您可以在通过身份验证后使用 Facebook Webdriver 进行登录和抓取。