Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > POST value related question

Reply
Thread Tools

POST value related question

 
 
ken
Guest
Posts: n/a
 
      10-13-2009
hello
i have some problem to send POST value by use mechanize.
i can't write my article to my blog site.

here is full source. and what i want to do is, im posting my article
to my blog site.
thanks in advance.

# -*- coding: cp949 -*-
import mechanize
import cookielib

# Browser
br = mechanize.Browser()

# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshP rocessor(),
max_time=1)

# Want debugging messages?
#br.set_debug_http(True)
#br.set_debug_redirects(True)
#br.set_debug_responses(True)

# User-Agent (this is cheating, ok?)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686;
en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/
3.0.1')]

# Open some site, let's pick a random one, the first that pops in
mind:
r = br.open('http://nid.naver.com/nidlogin.login')
html = r.read()
#print html


# Show the source
#print html
# or
#print br.response().read()

# Show the html title
#print br.title()

# Show the response headers
#print r.info()
# or
#print br.response().info()

# Show the available forms
for f in br.forms():
print f

# Select the first (index zero) form
br.select_form(nr=0)

# Let's search
br.form['id']='lbu142vj'
br.form['sID']=['on']
br.form['pw']='wbelryl'
br.submit()
#print br.response().read()
r = br.open("http://www.naver.com")
rs = r.read().decode('utf-8')
#print rs
r = br.open("http://blog.naver.com/PostWriteForm.nhn?
Redirect=Write&blogId=lbu142vj&widgetTypeCall=true ")
rs = r.read()
print rs

for f in br.forms():
print f

br.select_form(nr=0)
br.form['post.category.categoryNo']="[*1]"
br.form['post.title']='subject'
br.form['contents.contentsValue'] = 'content'
br.submit()
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
POST value related question ken Python 0 10-12-2009 09:18 PM
POST value related question james27 Python 1 10-12-2009 04:03 PM
How should multiple (related) projects be arranged (structured) and configured so that they can share code, have a related package structure and enable proper unittesting, and ensuring no namespace collisions ToddLMorgan@gmail.com Python 14 04-21-2006 04:03 PM
How should threads be terminated? (related to 'Help with thread related tracebacks') Maxwell Hammer Python 7 06-18-2005 04:20 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM



Advertisments