BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / www-technology / #20194同步于 2013/5/22
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖

python 求助!!!急

yiwangasheng
2013/5/22镜像同步4 回复
业余选手,实习公司要写个 python脚本,用get方式请求公司内部一个https网页信息,运行结果一直是这样的: 401 Unauthorized <html><head><title>Apache Tomcat/6.0.36 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - Please use https for Basic authentication and make sure Kerberos setup is working.</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Please use https for Basic authentication and make sure Kerberos setup is working.</u></p><p><b>description</b> <u>This request requires HTTP authentication.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.36</h3></body></html> 我写的脚本是这样的: import ssl import httplib conn=httplib.HTTPSConnection("greener-cn.amazon.com:8443") headers={"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Encoding":"gzip, deflate", "Connection":"keep-alive", "Host":"greener-cn.amazon.com:8443", "Referer":"https://greener-cn.amazon.com:8443/cgi/bsf.cgi?service=OrderingManipulationAuthority&path=%2Foma-cn%2F&host=oma-middle-cn.amazon.com&port=9662&timeout=10&method=getCustomerOrderByOrderId&app=pasture&params=%27orderId%27%3D%3E%27C03-0938426-8396647%27", "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0" } conn.request("GET","/cgi/bsf.cgi?service=OrderingManipulationAuthority&path=%2Foma-cn%2F&host=oma-middle-cn.amazon.com&port=9662&timeout=10&method=getCustomerOrderByOrderId&app=pasture&params='orderId'%3D>'C03-0938426-8396647'","",headers) r1=conn.getresponse() print r1.status,r1.reason print r1.read() 本人扣扣:972923391,可以直接说。 谢谢谢谢
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
nuanyangyang机器人#1 · 2013/5/22
http://stackoverflow.com/questions/635113/python-urllib2-basic-http-authentication-and-tr-im 话说你在Amazon实习吗?就是那个把公司内部所有的服务都用Web Service实现的公司?
yiwangasheng机器人#2 · 2013/5/22
是的,这个页面提交信息的时候,不是post,是get的,但是结果总是401 Unauthorized 不知道为啥了。。。 【 在 nuanyangyang 的大作中提到: 】 : http://stackoverflow.com/questions/635113/python-urllib2-basic-http-authentication-and-tr-im : 话说你在Amazon实习吗?就是那个把公司内部所有的服务都用Web Service实现的公司? :
nuanyangyang机器人#3 · 2013/5/22
注意观察: <body><h1>HTTP Status 401 - Please use https for Basic authentication and make sure Kerberos setup is working.</h1>
reverland机器人#4 · 2013/5/27
还是requests好用