在Firefox和Python中使用Mozrepl插件可以:
>>> import telnetlib
>>> tn = telnetlib.Telnet(r'127.0.0.1', 4242, 5)
>>> tn.read_eager()
'\nWelcome to MozRepl.\n\n - If you get stuck at the "'
>>> tn.read_until("repl> ")
...snip...
>>> tn.write(r'alert(window.content.location.href)'+"\n")
我得到了一个带有活动标签的URL的警告框。但是如何将URL读入python变量呢?类似于tn.write(r';var zz = window.content.location.href'+ "\n")
的内容,但这并不能将其引入python。在
我会很感激你的帮助。在
这可以使用pymozrepl模块完成。在
回答有点晚,但希望有用。。。在
您只需再次读取telnet连接,mozrepl的输出就会出现在那里。一定要注意返回的新行和引用的字符串。在
相关问题 更多 >
编程相关推荐