推荐学习书目
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 · Oct 8, 2014 · 3277 views
    This topic created in 4262 days ago, the information mentioned may be changed or developed.
    用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 replies    2015-01-09 20:35:11 +08:00
    no13bus
        1
    no13bus  
    OP
       Oct 8, 2014
    好像解决了。直接用
    for item in animals.split(';'):
    exec(item.replace('var','').strip())

    exec即可。不知道大家还有没有什么别的优雅的解决办法。
    yaotian
        2
    yaotian  
       Jan 9, 2015
    @no13bus 后来解决了吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5964 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 112ms · UTC 02:47 · PVG 10:47 · LAX 19:47 · JFK 22:47
    ♥ Do have faith in what you're doing.