Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66684
| Path | csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <kwpolska@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'parameters': 0.04; 'api.': 0.05; 'subject:Python': 0.06; 'session.': 0.07; 'utf-8': 0.07; 'correct,': 0.09; 'subject:script': 0.09; 'cc:addr:python-list': 0.11; 'record,': 0.16; 'subject:login': 0.16; 'work.)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'feb': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'login': 0.25; '(for': 0.26; 'code:': 0.26; 'asking': 0.27; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'related': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'requests': 0.31; 'coded': 0.31; 'though.': 0.31; 'username': 0.31; 'sense': 0.34; 'there,': 0.34; 'received:google.com': 0.35; 'server': 0.38; 'pm,': 0.38; 'logged': 0.60; 'from:charset:utf-8': 0.61; 'simply': 0.61; 'real': 0.63; 'decided': 0.64; 'skip:\xe2 10': 0.65; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'request.': 0.70; '8bit%:43': 0.74; 'leo': 0.84; 'phpbb': 0.84; 'url:mode': 0.84; 'url:php': 0.85; 'url:login': 0.93; 'url:tk': 0.95 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=0IwXKh4b2po3oddhgxZQiP9uTF+mditUgoBXm9q5I9k=; b=ifSvk1UfCPVXMasfTKtRYDrBz0zbKzz1huasQDS7aBhmJ8qiwjmQk5LBbzwEXBTAJG QoBXx+v5OeYuKJUPs6WXfSqqSuVJnYDwanXSb2+YfxovdkuHA9UUFtKFQaeTFQIefpBM z+XwpEKV2clIytzYuMND3XU5KgZLlKj2DjoZscJHRi8yAZ3XjbGqz1c6Xidtuq9tEVm/ alU1on1v5MmiJg+CAtrDmPwqX8JF6GE4LtC90uQJEac+kUC0W48OrTcjQlS5h1cveIqM QLFUZPTD4RZ8sx00qxD1TUemmgaRBLc7Yy3EaRr8Tfm2e81Kpo+SN232Xr0wIAZKa6l7 Nogw== |
| MIME-Version | 1.0 |
| X-Received | by 10.53.8.166 with SMTP id dl6mr175188vdd.60.1392810601834; Wed, 19 Feb 2014 03:50:01 -0800 (PST) |
| In-Reply-To | <le25ak$2qq$1@dont-email.me> |
| References | <le25ak$2qq$1@dont-email.me> |
| Date | Wed, 19 Feb 2014 12:50:01 +0100 |
| Subject | Re: Python Requests script to login to a phpbb forum |
| From | Chris “Kwpolska” Warrick <kwpolska@gmail.com> |
| To | Leo <ttdhead@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7145.1392810604.18130.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392810604 news.xs4all.nl 2872 [2001:888:2000:d::a6]:43057 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66684 |
Show key headers only | View raw
On Wed, Feb 19, 2014 at 12:46 PM, Leo <ttdhead@gmail.com> wrote:
> Hi there,
>
> I have decided to jump in at the deep end to try and learn python. I have
> been able to get requests to pull the login page off the server and I think
> send the login request. I don't get logged in though. Please let me know if
> I would be better off asking in a phpBB related group or forum.
> Here is my code without username and password included:
You need cookies. In order to do it, simply use sessions instead of
the “global” API. Code:
import requests
payload = {'username': 'username', 'password': 'password'}
session = requests.Session()
r = session.post("http://www.tt-forums.net/ucp.php?mode=login",data=payload)
sidStart = r.text.find("sid")+4
sid = r.text[sidStart:sidStart+32]
parameters = {'mode': 'login', 'sid': sid}
r = session.post("http://www.tt-forums.net/ucp.php",params=parameters,data=payload)
if "Logout" in r.text: print("We are in")
(for the record, I added the session creation line and replaced
requests. with session. so it uses your session. This code was not
tested on a real phpBB forum; if everything you coded is correct, it
will work.)
--
Chris “Kwpolska” Warrick <http://kwpolska.tk>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Python Requests script to login to a phpbb forum Leo <ttdhead@gmail.com> - 2014-02-19 22:46 +1100 Re: Python Requests script to login to a phpbb forum Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-02-19 12:50 +0100
csiph-web