Por que o Python (com sarja) não quer me fazer login em uma caixa de correio do Yahoo aqui?
-
26-09-2019 - |
Pergunta
Qualquer um pode, por favor, me explicar o que está acontecendo aqui. Parece que Python se recusa a trabalhar (com sarja) quando estou tentando fazer login na minha caixa de correio no Yahoo:
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
IDLE 1.2.4
>>> import twill
>>> twill.shell.main()
-= Welcome to twill! =-
current page: *empty page*
>> go http://us.yahoo.com
==> at http://us.yahoo.com
current page: http://us.yahoo.com
>> follow Mail
==> at https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym
current page: https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym
>> showforms
Form name=login_form (#1)
## ## __Name__________________ __Type___ __ID________ __Value__________________
1 .tries hidden (None) 1
2 .src hidden (None) ym
3 .md5 hidden (None)
4 .hash hidden (None)
5 .js hidden (None)
6 .last hidden (None)
7 promo hidden (None)
8 .intl hidden (None) us
9 .bypass hidden (None)
10 .partner hidden (None)
11 .u hidden (None) 68gre5567rq16
12 .v hidden (None) 0
13 .challenge hidden (None) 9wKUoOWDdP5Fho0kPfqPKEhPZBdK
14 .yplus hidden (None)
15 .emailCode hidden (None)
16 pkg hidden (None)
17 stepid hidden (None)
18 .ev hidden (None)
19 hasMsgr hidden (None) 0
20 .chkP hidden (None) Y
21 .done hidden (None) http://mail.yahoo.com
22 .pd hidden (None) ym_ver=0&c=&ivt=&sg=
23 pad hidden pad 6
24 aad hidden aad 6
25 login text username
26 passwd password passwd
27 .persistent checkbox persistent [] of ['y']
28 1 .save submi ... .save
current page: https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym
>> fv 1 login *****************
current page: https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym
>> fv 1 passwd ***************
current page: https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym
>> submit
Note: submit is using submit button: name=".save", value=""
Following HTTP-EQUIV=REFRESH to http://us.mg5.mail.yahoo.com/dc/launch?.gx=1&.rand=b3a02cc8lb0aa
current page: http://us.mg5.mail.yahoo.com/dc/launch?.gx=1&.rand=b3a02cc8lb0aa
>> info
Page information:
URL: http://us.mg5.mail.yahoo.com/dc/launch?.gx=1&.rand=b3a02cc8lb0aa
HTTP code: 200
Content type: text/html; charset=utf-8 (HTML)
Page title: Yahoo! Mail
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
twill.shell.main()
File "C:\Python25\Lib\site-packages\twill\shell.py", line 383, in main
shell.cmdloop(welcome_msg)
File "C:\Python25\lib\cmd.py", line 142, in cmdloop
stop = self.onecmd(line)
File "C:\Python25\lib\cmd.py", line 219, in onecmd
return func(arg)
File "C:\Python25\Lib\site-packages\twill\shell.py", line 42, in do_cmd
print '\nERROR: %s\n' % (str(e),)
File "C:\Python25\lib\HTMLParser.py", line 59, in __str__
result = self.msg
AttributeError: 'ParseError' object has no attribute 'msg'
>>>
Atualização 1:
(Esta atualização é minha resposta para Robus)
Olá, Robus !!!
Primeiro de tudo, suponho que foi um erro de digitação quando você escreveu:
Aqui está o que eu fiz: fui para C: python26 lib site-packages twill-0.9-py2.6.egg twill outros_packages
Eu acho que você quis dizer esse caminho: "C: python26 lib site-packages twill Outros_packages"Caso contrário, não consigo ver essa pasta/diretório lá chamado"Twill-0.9-Py2.6.egg" - Existe apenas um arquivo com esse nome (aquele que eu acho que foi baixado durante a instalação do mecanize.) Por favor, diga -me se minha suposição está errada - eu posso não estar vendo algo muito óbvio aqui, pois sou apenas um novato .
Então, seguindo suas instruções, eu fiz isso:
Eu encontrei "C: python25 lib site-packages twill outros_packages_mechanize_dist"No meu computador (como você pode ver, não tenho Python26, mas o Python 25 instalado - isso também pode ser um problema)
Mudou seu nome para "_mechanize_dist_backup"(O caminho completo agora é"C: python25 lib site-packages twill outros_packages_mechanize_dist_backup")
Copiou meu baixado e descompactado "mecanize-0.2.2" em "C: python25 lib site-packages twill Outros_packages"(O caminho completo é"C: python25 lib site-packages twill outros_packages mecanize-0.2.2")
Mudou seu nome para "_mechanize_dist"(O caminho completo é"C: python25 lib site-packages twill outros_packages_mechanize_dist")
Copiado "Clientform"Arquivo de"_mechanize_dist_backup"E colou -o em"_mechanize_dist"(Na verdade, encontrei dois arquivos chamados"Clientform": Um é um arquivo python, outro é um arquivo python compilado - copiei e colei os dois).
Tendo feito isso, tentei executar todos esses comandos e fiquei preso desde o início - eu não conseguia nem importar a sarja agora:
IDLE 1.2.4
>>> import twill
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import twill
File "C:\Python25\Lib\site-packages\twill\__init__.py", line 52, in <module>
from shell import TwillCommandLoop
File "C:\Python25\Lib\site-packages\twill\shell.py", line 9, in <module>
from twill import commands, parse, __version__
File "C:\Python25\Lib\site-packages\twill\commands.py", line 7, in <module>
import _mechanize_dist as mechanize
ImportError: No module named _mechanize_dist
Parece que o sistema não reconhece o recém-criado "_mechanize_dist".
Poderia ser porque eu tenho Python 25 em vez do Python 26? Ou, talvez, haja algum outro motivo?
Solução
O problema está no mecanismo. Você precisa da versão mais recente
su
git clone git://github.com/jjlee/mechanize.git
cd mechanize
python setup.py install