Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11395
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.045 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'urllib2': 0.07; 'python': 0.08; 'received:209.85.160.174': 0.09; 'received:mail- gy0-f174.google.com': 0.09; 'subject:login': 0.16; 'cc:addr :python-list': 0.16; 'possibly': 0.16; 'url:blog': 0.16; 'cheers,': 0.18; "aren't": 0.21; 'cc:2**0': 0.22; 'header:In- Reply-To:1': 0.22; 'required.': 0.28; 'right.': 0.28; 'import': 0.28; 'message-id:@mail.gmail.com': 0.29; 'fix': 0.29; 'cc:addr:python.org': 0.30; 'html.': 0.30; "skip:' 10": 0.30; 'specified': 0.31; 'chris': 0.32; 'values': 0.32; 'probably': 0.33; "can't": 0.33; 'there': 0.33; 'rather': 0.35; 'received:209.85.160': 0.35; 'response': 0.37; 'page': 0.37; 'could': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'itself.': 0.39; 'subject:with': 0.39; 'appreciated.': 0.39; 'data': 0.39; 'case': 0.39; 'called': 0.40; 'login': 0.69; 'url:login': 0.77; 'sender:addr:chris': 0.84; 'url:hi': 0.84; 'url:rebertia': 0.84; 'to:none': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:cc:content-type :content-transfer-encoding; bh=glF1F1LYGLV36En9qjPhePOce5CEqk6EDbtIVybEVQw=; b=OBzb7D2Tv64mfGNFhdZ1XHQsPJzl4mvmykrXrG+RnVcNUgAB6C5au/M5NPUNmtpD7h 12aVvooiE5hBRBYrGMkUCbMqc6Bs3ODy/+6g05IDsiAC6HI2rhCl3zv0YSCoZ/PtOjnS sOErA52TtjoRKMVa1a64HPQBhXYnajMi5IxWM= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <tencent_6DD52AA454BF5A964A9B1269@qq.com> |
| References | <tencent_6DD52AA454BF5A964A9B1269@qq.com> |
| Date | Sun, 14 Aug 2011 08:07:37 -0700 |
| X-Google-Sender-Auth | oJCr7GkYlY3IkIFQ-UtrhMzxDNo |
| Subject | Re: login with urllib2 |
| From | Chris Rebert <clp2@rebertia.com> |
| Cc | python-list <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2274.1313334460.1164.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1313334460 news.xs4all.nl 23850 [2001:888:2000:d::a6]:35647 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:11395 |
Show key headers only | View raw
2011/8/14 守株待兔 <1248283536@qq.com>:
> please to see my code:
> import urllib
> import urllib2
>
> url = 'http://hi.baidu.com/'
> values = {'username' : '******','password' : '******' }
>
> data = urllib.urlencode(values)
> req = urllib2.Request(url,data)
> response = urllib2.urlopen(req)
> the_page = response.read()
>
> i can't to login ,why?username and password are right.
> any word appreciated.
Use the URL specified as the <form>'s action, which in this case is
https://passport.baidu.com/?login , rather than the URL of the login
page itself.
The <form> fields aren't called "username" and "password"; read the
page's HTML. You'll also see that there are a few hidden form fields
that are probably required.
Finally, even if you fix these problems, the site could possibly block
Python based on its User-agent header.
Cheers,
Chris
--
http://blog.rebertia.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: login with urllib2 Chris Rebert <clp2@rebertia.com> - 2011-08-14 08:07 -0700
csiph-web