LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

Rep: Reputation: 54
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?


Code:
#!/usr/bin/python
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, 'http://beta.coolsite.com')
crl.setopt(pycurl.USERAGENT, user_agent)
crl.setopt(pycurl.COOKIEFILE, '/tmp/cookie.txt')
crl.setopt(pycurl.COOKIEJAR, '/tmp/cookie.txt')
crl.perform()
crl.setopt(pycurl.POSTFIELDS, node_data)
crl.setopt(pycurl.URL, 'http://beta.coolsite.com/node/add/report')
crl.perform()
crl.close()
 
  


Reply


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 08:21 PM
LXer: Creating a user-centric site in Drupal LXer Syndicated Linux News 0 11-05-2008 12:20 PM
LXer: Entering A Safe Mirror When Logging In With Unionfs And Chroot LXer Syndicated Linux News 0 06-29-2007 11:01 AM
Python: Logging into a site Baix Programming 26 04-30-2007 09:41 AM
Qmail + vQregister not entering data into database lsimon4180 Linux - Software 0 03-25-2005 01:46 PM


All times are GMT -5. The time now is 05:11 AM.

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