Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Question about urllib and posting to an external script

Reply
Thread Tools

Question about urllib and posting to an external script

 
 
evanpmeth@gmail.com
Guest
Posts: n/a
 
      09-06-2006
I have tried multiple ways of posting information to a website and have
failed. I have seen this problem on other forums can someone explain or
point me to information on how POST works through urllib an different
broweser (what is the difference).

my first attempt was out of the docs:

Code:

import httplib, urllib params = urllib.urlencode({'email' : '(E-Mail Removed)',
'password' : 'pass'}) h = httplib.HTTP("login.myspace.com:80")
h.putrequest("POST", "/index.cfm?fuseaction=login.process&amp")
h.putheader("User-Agent", "Mozilla/5.0 <Windows; U; Windows NT 5.1;
en-US; rv;1.8.0.6> Gecko/20060728 Firefox/1.5.0.6")
h.putheader("Content-length", "%d" % len(params)) h.putheader('Accept',
'text/plain') h.endheaders() h.send(params) reply, msg, hdrs =
h.getreply() print reply # should be 200 data = h.getfile().read() #
get the raw HTML print data



this returned a page denying access
and then tried:

Code:

import httplib, urllib params = urllib.urlencode({'email' :
'(E-Mail Removed)', 'password' : 'dicksuck'})
data
=urllib.urlopen("http://login.myspace.com/index.cfm?fuseaction=login.process&amp:80",
params).read()
print data



This returned a page that asked me if i wanted to sign up, which
confused me even more.

all i want to do is post this form:
HTML Code:

<form method='POST' enctype='multipart/form-data'
action='http://login.myspace.com/index.cfm?fuseaction=login.process&amp'>
<input type="text" name="email" > <input type="password"
name="password" > <input type="submit" value="Login"/>



Please help i was thinking maybe the site did browser sniffing and only
allowed certain types of browsers. I dont know. I have seen this
problem on other forums can someone explain or point me to information
on how POST works through urllib an different broweser (what is the
difference).

 
Reply With Quote
 
 
 
 
alex23
Guest
Posts: n/a
 
      09-06-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> all i want to do is post this form:
> HTML Code:
>
> <form method='POST' enctype='multipart/form-data'
> action='http://login.myspace.com/index.cfm?fuseaction=login.process&amp'>
> <input type="text" name="email" > <input type="password"
> name="password" > <input type="submit" value="Login"/>


Heya,

It might help to use one of the higher-level abstractions for dealing
with the web. twill (http://twill.idyll.org/) provides a simple
language for scripting web-based interactions.

The example they provide should be useable as a basis for what you
want:
++++
setlocal username <your username>
setlocal password <your password>

go http://www.slashdot.org/
formvalue 1 unickname $username
formvalue 1 upasswd $password
submit

code 200 # make sure form submission is correct!
++++

I _think_ twill is based on top of mechanize
(http://wwwsearch.sourceforge.net/mechanize/) which may be of use to
you if twill obscures or hides functionality you need.

Hope this helps.

-alex23

 
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
2to3 urllib.URLopener -> urllib.request.URLopener Chris McDonald Python 0 11-01-2010 11:23 AM
Asynchronous urllib (urllib+asyncore)? Jonathan Gardner Python 1 02-27-2008 12:51 AM
Create references to external scipt files from within an external script file Mellow Crow Javascript 6 11-04-2005 01:16 PM
Top Posting vs. Bottom Posting scaredkitty Computer Support 37 04-06-2005 12:27 AM
Everytime I hover cursro over a posting, it crosses out with red mark on it.. on every posting alanb ASP .Net 2 04-23-2004 02:23 PM



Advertisments