V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
no13bus
V2EX  ›  Python

http://pachong.org/ 这个网站的主页里面的端口是用 js 代码生成的,js 里面的变量每次在打开网页的时候都会变化。那么里面的端口那个值怎么获取到呢?

  •  
  •   no13bus ·
    no13bus · 2014-10-08 10:53:28 +08:00 · 2736 次点击
    这是一个创建于 3487 天前的主题,其中的信息可能已经有所发展或是发生改变。
    用python写的脚本,爬取他的端口。但是他的端口是通过他实现的。<script>document.write((15807^goat)+812);</script> 里面的goat是通过var goat=6111+7380;var hen=5548+7476^goat;var seal=2094+4451^hen;var rat=1687+7000^seal;var pig=3997+8240^rat; 这个js实现的,但是每次打开网页的时候,这里面的变量名称和值都会变化。想问下,这样的话 怎么获取他的端口?

    下面是自己的gist. 想通过goat=6111+7380这个字串直接在python里面产生一个goat变量并且赋值给他。但是没成功。

    2 条回复    2015-01-09 20:35:11 +08:00
    no13bus
        1
    no13bus  
    OP
       2014-10-08 11:01:57 +08:00
    好像解决了。直接用
    for item in animals.split(';'):
    exec(item.replace('var','').strip())

    exec即可。不知道大家还有没有什么别的优雅的解决办法。
    yaotian
        2
    yaotian  
       2015-01-09 20:35:11 +08:00
    @no13bus 后来解决了吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1437 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:30 · PVG 01:30 · LAX 10:30 · JFK 13:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.