用 requests 中的 post 正方教务系统后返回中的 text 中没有回应的文本? - V2EX
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
xyxc0673
V2EX    Python

用 requests 中的 post 正方教务系统后返回中的 text 中没有回应的文本?

  •  
  •   xyxc0673
    xyxc0673 2016-05-30 21:54:39 +08:00 4044 次点击
    这是一个创建于 3445 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我在用 requests post 正方教务系统时,发现返回的 text 中没有什么用户名错误或者密码错误或者验证码错误之类的(以 js 嵌在源代码中)。
    网址是 http://jw.jluzh.com/
    想看下各位大神是否也是这样
    10 条回复    2016-05-31 08:43:23 +08:00
    xyxc0673
        1
    xyxc0673  
    OP
       2016-05-30 22:00:57 +08:00
    缩减的代码,验证码获取那段删除了
    import requests

    payload = {
    '__VIEWSTATE': "dDwyODE2NTM0OTg7Oz6axkqPO5u6m/sWzhMWZ6hy71QBYA==",
    'txtUserName': "123456",
    'TextBox2': "123456",
    'txtSecretCode':"1234",
    'RadioButtonList1': "学生",
    'Button1:': '',
    'lbLanguage': '',
    'hidPdrs': '',
    'hidsc': ''
    }

    headers = {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'Accept-Language': 'zh-CN,zh;q=0.8',
    'Connection': 'keep-alive',
    'Content-Type': 'application/x-www-form-urlencoded',
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36"
    }

    r = requests.post("http://125.89.69.234/default2.aspx", headers = headers)
    print(r.text)
    est
        2
    est  
       2016-05-30 22:03:09 +08:00
    试试 r.content

    另外 requests 有 encoding 的坑。建议 r.encoding = None
    xyxc0673
        3
    xyxc0673  
    OP
       2016-05-30 22:11:01 +08:00
    @est 还是一样没有提示。。。
    pathletboy
        4
    pathletboy  
       2016-05-30 22:38:53 +08:00
    2 点
    1 、你 payload 没发出去
    2 、'Button1:': '', 这个多了个 :
    xyxc0673
        5
    xyxc0673  
    OP
       2016-05-30 22:41:30 +08:00
    @pathletboy 第二点!!!
    xyxc0673
        6
    xyxc0673  
    OP
       2016-05-30 22:41:45 +08:00
    @pathletboy 谢谢!
    cwlmxwb
        7
    cwlmxwb  
       2016-05-30 22:46:57 +08:00 via iPad
    验证码你是采用获取图片人工输入还是用图像识别
    xyxc0673
        8
    xyxc0673  
    OP
       2016-05-30 23:05:49 +08:00
    @cwlmxwb 手动输入
    atnoot
        9
    atnoot  
       2016-05-30 23:28:18 +08:00
    post 之后会自动跳转? 可以 dir 一下 r 的方法 爬过几个网站 貌似 post 之后会去 get 某个页面
    xyxc0673
        10
    xyxc0673  
    OP
       2016-05-31 08:43:23 +08:00
    @atnoot 现在问题是如果我输入错误的信息的 text 都会有相应提示,但是如果我输入正确的信息返回的 text 中是登录页面的代码,然后 cookies 也是空的,是什么原因?
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1391 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 22ms UTC 17:06 PVG 01:06 LAX 09:06 JFK 12:06
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86