V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Vicer
V2EX  ›  问与答

小白请教一个关于 Python 的问题。

  •  
  •   Vicer · Oct 19, 2015 · 2017 views
    This topic created in 3847 days ago, the information mentioned may be changed or developed.

    部分代码如下:

    登陆

    url = 'https://bbs.tianshi2.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&inajax=1';
    postData = urllib.urlencode({'username': self.userName, 'password': self.password, 'answer': '', 'cookietime': '2592000', 'handlekey': 'ls', 'questionid': '0', 'quickforward': 'yes',  'fastloginfield': 'username'})
    req = urllib2.Request(url,postData)
    

    签到

    url = 'https://bbs.tianshi2.com/plugin.php?id=dsu_paulsign:sign&operation=sign&infloat=1&inajax=1'
    postData = urllib.urlencode({'fastreply': '1', 'formhash': self.formhash, 'qdxq': self.qdxq, 'todaysay': msg.encode('gbk')})
    req = urllib2.Request(url,postData)
    

    只是部分代码,上面这部分代码给 www.gn00.com 就可以签到成功!
    为什么给 bbs.tianshi2.com 就不能签到成功?
    请问什么该怎么修改?

    3 replies    2015-10-19 22:38:51 +08:00
    Septembers
        1
    Septembers  
       Oct 19, 2015 via iPad
    这不是 python 的问题

    或许站长魔改过
    Vicer
        2
    Vicer  
    OP
       Oct 19, 2015 via iPhone
    @Septembers 那能不能帮写个?
    Kilerd
        3
    Kilerd  
       Oct 19, 2015
    自己抓包,然后就可以写啦。

    BTW, requests 大法好,不要用 urllib 了。目前用到 urllib 的地方只有用于下载图片
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   779 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 20:40 · PVG 04:40 · LAX 13:40 · JFK 16:40
    ♥ Do have faith in what you're doing.