same code to login,one is ok,another is not

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Aug 14 20:55:53 EDT 2011


守株待兔 wrote:

> 1.http://www.renren.com/Login.do
> it is ok,my code:
[...]
> 2.https://passport.baidu.com/?login
> can't login,my code:
[...]

Do you have a question, or are you just sharing the bad news?

Websites may choose to respond to login attempts differently. Some may
require cookies, some may not. Some may check the referrer, some may not.
Some may look at the user agent, some may not.

If the web developer of the site insists that you log in with a browser, or
Internet Explorer, you have to fight to convince the web server to let you
in. Many websites really try hard to prevent bots and scripts logging in.
The closer you can imitate what a real human being in a browser does, the
better the chances you can fool the server that you are a real human being
using a browser and not a bot. (Since your script *is* a bot, you may also
be in violation of the web site's terms of service.)

Some web sites may even check how often you try to log in, or how fast.

But what makes you think you can't log in? Given the response below, it
looks to me that you did log in, and got a blank page with some javascript
to redirect you to the real content page. (If you are a web developer and
you do this, I hate you.) But I may be wrong -- I'm not an expert on these
things.


> <!--STATUS OK-->
> <html><head><title>������§��������      </title>
> <meta http-equiv=content-type content="text/html; charset=gb2312">
> <META http-equiv='Pragma' content='no-cache'>
> </head>
> <body>
>  
>          
>              
>             <script>
>             var url="./?pwd=1"
>             url=url.replace(/^\.\//gi,"http://passport.baidu.com/");
>             location.href=url;
>             </script>
>              
>          
>  
> </body>
> </html>


-- 
Steven




More information about the Python-list mailing list