Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-16-2009, 09:56 PM   #1
Gentoo Developer
Registered: Feb 2004
Location: Fort Lauderdale FL.
Distribution: Gentoo
Posts: 3,291
Blog Entries: 5

Rep: Reputation: 56
Logging into a Drupal site and entering data (pycurl Python)

I can log into the site fine. I can post the title fine, but the fields only produce "f" without the quotes.
Any Ideas?

import urllib
import pycurl

user_agent = 'Mozilla/4.0 (compatible: MSIE 6.0)'
login = [('name', 'username'),
        ('pass', 'passwd'),
        ('form_id', 'user_login'),
        ('form_build_id', ''),
        ('op', 'Log in')]
login_data = urllib.urlencode(login)
node = [('title', 'Pycurl Test'),
        ('field_cbuild', 'Test cbuild'),
        ('field_cflags', 'Test cflags'),
        ('field_accepted_keywords', 'Test keywords'),
        ('changed', ''),
        ('form_id', 'report_node_form'),
        ('form_build_id', ''),
        ('form_token', '4b4925e0541b2f11722e7e409453d099'),
        ('op', 'Save')]
login_data = urllib.urlencode(login)
node_data = urllib.urlencode(node)
print node_data
crl = pycurl.Curl()
crl.setopt(pycurl.POSTFIELDS, login_data)
crl.setopt(pycurl.URL, '')
crl.setopt(pycurl.USERAGENT, user_agent)
crl.setopt(pycurl.COOKIEFILE, '/tmp/cookie.txt')
crl.setopt(pycurl.COOKIEJAR, '/tmp/cookie.txt')
crl.setopt(pycurl.POSTFIELDS, node_data)
crl.setopt(pycurl.URL, '')


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make python programs run without entering the command python? trist007 Programming 5 03-22-2009 09:21 PM
LXer: Creating a user-centric site in Drupal LXer Syndicated Linux News 0 11-05-2008 01:20 PM
LXer: Entering A Safe Mirror When Logging In With Unionfs And Chroot LXer Syndicated Linux News 0 06-29-2007 12:01 PM
Python: Logging into a site Baix Programming 26 04-30-2007 10:41 AM
Qmail + vQregister not entering data into database lsimon4180 Linux - Software 0 03-25-2005 02:46 PM

All times are GMT -5. The time now is 09:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration