Login to Drupal 6 site using pycurl

D

David

I can not get this to work;

#!/usr/bin/python
import urllib
import pycurl

user_agent = 'Mozilla/4.0 (compatible: MSIE 6.0)'
crl = pycurl.Curl()
crl.setopt(pycurl.URL, 'http://beta.gentooligans.com')
crl.setopt(pycurl.HEADER, 1)
crl.setopt(pycurl.USERAGENT, user_agent)
crl.setopt(pycurl.FOLLOWLOCATION, 1)
crl.setopt(pycurl.COOKIEFILE, '/tmp/cookie.txt')
crl.setopt(pycurl.COOKIEJAR, '/tmp/cookie.txt')
login = [('name', 'username'),
('pass', 'password'),
('form-id', 'user_login'),
('op', 'Log in')]
login_data = urllib.urlencode(login)
crl.setopt(pycurl.POSTFIELDS, login_data)
crl.setopt(pycurl.URL, 'http://beta.gentooligans.com/user/login')
crl.perform()
crl.close()

I tried it like this also;

('edit[name]', user),
('edit[pass]', password),


output

[snip]

<body class="not-logged-in not-front layout-first-main
preface-first-middle-last postscript-first-middle-last">
<div id="navigation"><div id="user-bar"><form
action="/user/login?destination=user%2Flogin" accept-charset="UTF-8"
method="post" id="user-login-form">
<div><div class="form-item" id="edit-name-1-wrapper">
<label for="edit-name-1">Username: <span class="form-required"
title="This field is required.">*</span></label>
<input type="text" maxlength="60" name="name" id="edit-name-1"
size="15" value="" class="form-text required" />
</div>
<div class="form-item" id="edit-pass-1-wrapper">
<label for="edit-pass-1">Password: <span class="form-required"
title="This field is required.">*</span></label>
<input type="password" name="pass" id="edit-pass-1" maxlength="60"
size="15" class="form-text required" />
</div>
<input type="submit" name="op" id="edit-submit-2" value="Log in"
class="form-submit" />

[snip]

Here are some guides I used;
http://code.activestate.com/recipes/267255/
http://drupal.org/node/87711

thanks,
-david
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top