Как программно получить доступ к защищенному паролем веб-сайту?

Для тех, у кого не установлен pip, я нашел этот быстрый скрипт на github (работает с Python 2.7.13):

import pkg_resources
distros = pkg_resources.AvailableDistributions()
for key in distros:
  print distros[key]

7
задан Prashant 9 July 2009 в 05:20
поделиться

4 ответа

11
ответ дан 6 December 2019 в 09:21
поделиться

jQuery поддерживает HTTP-аутентификацию с помощью метода ajax (). Примерно так должно работать:

jQuery.ajax({
    type: "GET",
    url: "foo.php",
    username: "foo",
    password: "bar"
});

Документацию по всем параметрам jQuery.ajax () можно найти здесь: http://docs.jquery.com/Ajax/jQuery.ajax#options

4
ответ дан 6 December 2019 в 09:21
поделиться

это, конечно, не ajax, но с клиентом wget вы можете использовать флаги --http-user и --http-password

2
ответ дан 6 December 2019 в 09:21
поделиться

In general, http://user:pass@example.com

But there are some obvious security shortcomings with that.

A more complete solution may be to set a Session variable after a user is authenticated.

Make the AJAX post to a script that checks authentication. If authenticated, use CURL to fetch the results using a pre-defined authorized account.

This allows you to re-use basic apache auth but prevents any passwords from being written in the DOM.

3
ответ дан 6 December 2019 в 09:21
поделиться
Другие вопросы по тегам:

Похожие вопросы: