为什么Python(带有斜纹)不想让我登录到这里的雅虎邮箱?

发布于 2024-09-17 00:02:59 字数 6490 浏览 2 评论 0原文

任何人都可以向我解释一下这是怎么回事吗?当我尝试登录雅虎邮箱时,Python 似乎拒绝工作(使用斜纹):

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'
>>> 

更新 1:(

此更新是我对 Robus 的回答)

你好,Robus!

首先,我认为您写下的内容是一个错字:


这就是我所做的:去了 C:\Python26\Lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\


我想你的意思是这个路径:“C:\Python26\Lib\site-packages\twill\other_packages ”。否则,我看不到任何名为“twill-0.9-py2.6.egg”的文件夹/目录 - 只有一个具有此名称的文件(我认为是在机械化的安装。)请告诉我我的假设是否错误 - 我很可能在这里看不到非常明显的东西,因为我只是一个新手。

因此,按照您的指示,我这样做了:

  1. 我在我的计算机上找到了“C:\Python25\Lib\site-packages\twill\other_packages_mechanize_dist”(如您所见,我不'没有安装 python26,而是安装了 python 25 - 这也可能是一个问题)

  2. 将其名称更改为“_mechanize_dist_backup”(完整路径现在为“< strong>C:\Python25\Lib\site-packages\twill\other_packages_mechanize_dist_backup")

  3. 将我下载并解压的“mechanize-0.2.2”复制到“C:\ Python25\Lib\site-packages\twill\other_packages”(完整路径为“C:\Python25\Lib\site-packages\twill\other_packages\mechanize-0.2.2” )

  4. 将其名称更改为“_mechanize_dist” (完整路径为“C:\Python25\Lib\site-packages\twill\other_packages_mechanize_dist”)

  5. 从“_mechanize_dist_backup”复制“ClientForm”文件>”并将其粘贴到“_mechanize_dist”中(事实上,我在那里发现了两个名为“ClientForm”的文件:一个是python文件,另一个是编译后的python文件- 我复制并粘贴了它们)。

完成此操作后,我尝试运行所有这些命令,但一开始就陷入困境 - 现在我什至无法导入斜纹:


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

系统似乎无法识别新创建的“_mechanize_dist” 。

难道是因为我有 Python 25 而不是 Python 26?或者,也许还有其他原因?

Can anyone, please, explain to me what's going on here. It seems that Python refuses to work (with twill) when I am trying to log in to my mailbox on 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'
>>> 

Update 1:

(this update is my answer to Robus)

Hello, Robus!!!

First of all, I assume it was a typo when You wrote:


Here's what I did: Went to
C:\Python26\Lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\


I think You meant this path: "C:\Python26\Lib\site-packages\twill\other_packages". Otherwise, I can't see any such folder/directory there named "twill-0.9-py2.6.egg" - there is only a file with this name (the one that I think was downloaded during the installation of mechanize.) Please tell me if my assumption is wrong - I may well be not seeing something very obvious here as I am just a newbie.

So, following Your instructions, I did this:

  1. I found "C:\Python25\Lib\site-packages\twill\other_packages_mechanize_dist" on my computer (as You can see, I don't have python26, but rather python 25 installed - that might also be a problem)

  2. Changed its name to "_mechanize_dist_backup" (the full path now being "C:\Python25\Lib\site-packages\twill\other_packages_mechanize_dist_backup")

  3. Copied my downloaded and unzipped "mechanize-0.2.2" into "C:\Python25\Lib\site-packages\twill\other_packages" (the full path being "C:\Python25\Lib\site-packages\twill\other_packages\mechanize-0.2.2")

  4. Changed its name to "_mechanize_dist" (the full path being "C:\Python25\Lib\site-packages\twill\other_packages_mechanize_dist")

  5. Copied "ClientForm" file from "_mechanize_dist_backup" and pasted it in "_mechanize_dist" (in fact, I found two files there named "ClientForm": one is a python file, another one is a compiled python file - I copied and pasted both of them).

Having done that, I tried running all those commands and got stuck at the very beginning - I couldn't even import twill now:


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

It seems that the system doesn't recognize the newly-created "_mechanize_dist".

Could it be because I have Python 25 instead of Python 26? Or, perhaps, there is some other reason?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对岸观火 2024-09-24 00:02:59

问题出在机械化上。你需要最新版本

su
git clone git://github.com/jjlee/mechanize.git
cd mechanize
python setup.py install

The problem lies in Mechanize. You need the newest version

su
git clone git://github.com/jjlee/mechanize.git
cd mechanize
python setup.py install
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文