wind3110991
V2EX  ›  问与答

最近教务系统升级了。。用 python 爬时, URL 被加密了无法操作模拟登陆

  •  
  •   wind3110991 · Apr 18, 2015 · 5048 views
    This topic created in 4218 days ago, the information mentioned may be changed or developed.

    Header里的信息:

    General
    Remote Address:222.201.132.116:80
    Request URL:http://222.201.132.116/(wa4qm345dj1m5i55qectnu22)/default2.aspx
    Request Method:POST
    Status Code:302 Found

    Cache-Control:no-cache, no-store
    Content-Length:173
    Content-Type:text/html; charset=gb2312
    Date:Sat, 18 Apr 2015 13:43:18 GMT
    Expires:-1
    Location:/(wa4qm345dj1m5i55qectnu22)/xs_main.aspx?xh=(这里是我的教务系统ID)
    P3P:CP=CAO PSA OUR
    Pragma:no-cache
    Pragma:no-cache
    Server:Microsoft-IIS/6.0
    X-AspNet-Version:1.1.4322
    X-Powered-By:ASP.NET

    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
    Accept-Encoding:gzip, deflate
    Accept-Language:zh-CN,zh;q=0.8
    Cache-Control:max-age=0
    Connection:keep-alive
    Content-Length:198
    Content-Type:application/x-www-form-urlencoded
    Host:222.201.132.116
    Origin:http://222.201.132.116
    Referer:http://222.201.132.116/(wa4qm345dj1m5i55qectnu22)/default2.aspx
    User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2369.0 Safari/537.36

    __VIEWSTATE:dDwyODE2NTM0OTg7Oz5VGnjXV87Z19Dm3QbgRgvcptEYyA==
    txtUserName:(我的ID)
    TextBox2:(我的密码)
    txtSecretCode:xwcu
    RadioButtonList1:(unable to decode value)
    Button1:
    lbLanguage:
    hidPdrs:
    hidsc:

    主要是URL:http://222.201.132.116/(wa4qm345dj1m5i55qectnu22)/default2.aspx
    这个URL中间是什么加密方法啊? = =

    自己模拟登陆的代码:

    import urllib
    import urllib2
    import cookielib
    import re
    
    class SCUT:
    
        def __init__(self):
            self.loginUrl = '这里是Login的URL'
            self.cookies = cookielib.CookieJar()
            self.postdata = urllib.urlencode({
                'txtUserName:':'我的ID',
                'TextBox2':'我的密码'
             })
            self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookies))
    
        def getPage(self):
            request  = urllib2.Request(
                url = self.loginUrl,
                data = self.postdata)
            result = self.opener.open(request)
            #打印登录内容
            print result.read().decode('gbk')
    
    
    scut = SCUT()
    scut.getPage()
    

    有大神知道如何解决吗?

    21 replies  •  2015-04-19 21:42:01 +08:00
    binux
    binux
    Apr 18, 2015 via Android
    1
    你有没有想过,如果“加密”了,浏览器是怎么登录的?
    decken
    decken
    Apr 18, 2015 via Android
    2
    可以先获取被"加密"的登录URL
    NewYear
    NewYear
    Apr 18, 2015
    3
    @binux 根本就没加密,先抓取一下/路径,就会跳转,数据都写在包头里了。
    lk09364
    lk09364
    Apr 18, 2015
    4
    duplicate of /t/184559
    我这边 __VIEWSTATE 内容和你的一样,看来这个直接传回去就可以。
    Ghoul2005
    Ghoul2005
    Apr 18, 2015
    5
    只要没有验证码,都没有任何障碍,只是多请求一两个页面而已。
    chaucerling
    chaucerling
    Apr 18, 2015
    6
    请求的是frame的地址<frame src="http://jw2005.scuteo.com/">
    response header返回一个重定向的地址
    Location:/(gx4jp0repbkmkn45u5muqlqu)/Default.aspx
    chaucerling
    chaucerling
    Apr 18, 2015
    7
    之后又两个重定向,真蛋疼
    Location:http://222.201.132.117/default2.aspx
    Location:/(bpkwxe55m0gnz23beiprl545)/default2.aspx
    RIcter
    RIcter
    Apr 18, 2015 via iPhone
    8
    這教務系統有漏洞的_(:з」∠)_好像
    cxe2v
    cxe2v
    Apr 19, 2015
    9
    @RIcter 教务系统基本都是漏洞一堆的
    wind3110991
    wind3110991
    OP
    Apr 19, 2015
    10
    @NewYear 那应该怎么操作?
    wind3110991
    wind3110991
    OP
    Apr 19, 2015
    11
    @lk09364 什么意思啊
    sb
    sb
    Apr 19, 2015
    12
    那串东西是个session, 你提取出来给拼装上就好。
    lgh
    lgh
    Apr 19, 2015
    13
    母校……
    trepwq
    trepwq
    Apr 19, 2015 via iPhone
    14
    母校。。。
    oott123
    oott123
    Apr 19, 2015
    15
    PhantomJS 大法好
    messagebus
    messagebus
    Apr 19, 2015 via iPhone
    16
    去年做过一个这样的,没难度,代码搞丢了
    NewYear
    NewYear
    Apr 19, 2015
    17
    @wind3110991 先用你的组件/插件/类/控件访问http://222.201.132.116/这个地址,但是要禁止跳转,然后获取HTTP头部的跳转信息Location这部分,就是你说的“加密”部分了啊。然后以后访问的网址部分,都带上这个,不就好了。
    welsmann
    welsmann
    Apr 19, 2015
    18
    看路径就知道是正方.....
    bestie
    bestie
    Apr 19, 2015
    19
    华南皇家理工大学, 轮子哥一个学校
    Comdex
    Comdex
    Apr 19, 2015
    20
    @NewYear
    @wind3110991 17楼正解
    endoffight
    endoffight
    Apr 19, 2015 via Android
    21
    http://202.200.112.200
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2422 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 15:36 · PVG 23:36 · LAX 07:36 · JFK 10:36
    ♥ Do have faith in what you're doing.