I have tried multiple ways of posting information to a website and have failed.
my first attempt was out of the docs: - import httplib, urllib
-
params = urllib.urlencode({'email' : 'a@a.com', 'password' : 'pass'})
-
h = httplib.HTTP("login.myspace.com:80")
-
h.putrequest("POST", "/index.cfm?fuseaction=login.process&")
-
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: - import httplib, urllib
-
params = urllib.urlencode({'email' : 'ezikz@bonbon.net', 'password' : 'dicksuck'})
-
data = urllib.urlopen("http://login.myspace.com/index.cfm?fuseaction=login.process&: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]<form method='POST' enctype='multip art/form-data' action='http://login.myspace.c om/index.cfm?fusea ction=login.pro cess&'>
<input type="text" name="email" >
<input type="password" name="password" >
<input type="submit" value="Login"/>[/HTML]
Please help i was thinking maybe the site did browser sniffing and only allowed certain types. i dont know.
2 3183
Get ClientCookie from http://wwwsearch.sourceforge.net/ClientCookie/
Inside the ClientCookie-x.x.x directory, you will find a directory called ClientCookie. Copy it to C:\Python2x\Lib \site-packages.
Change youremail, yourpassword, and anyfriendid in the following code: - import urllib
-
import urllib2
-
import ClientCookie
-
-
params = urllib.urlencode({'email':'youremail','password':'yourpassword'})
-
request = urllib2.Request("http://login.myspace.com/index.cfm?fuseaction=login.process&",params)
-
response = urllib2.urlopen(request)
-
c = ClientCookie.Cookies()
-
c.extract_cookies(response,request)
-
request2 = urllib2.Request("http://comment.myspace.com/index.cfm?fuseaction=user.viewComments&friendID=anyfriendid")
-
c.add_cookie_header(request2)
-
url2 = urllib2.urlopen(request2)
This loads (as an example) the View All Comments page of the user with anyfriendid--something you must be logged in to do. If you wish to do something else, it should be easy to infer how.
I have tried multiple ways of posting information to a website and have failed.
my first attempt was out of the docs: - import httplib, urllib
-
params = urllib.urlencode({'email' : 'a@a.com', 'password' : 'pass'})
-
h = httplib.HTTP("login.myspace.com:80")
-
h.putrequest("POST", "/index.cfm?fuseaction=login.process&")
-
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: - import httplib, urllib
-
params = urllib.urlencode({'email' : 'ezikz@bonbon.net', 'password' : 'dicksuck'})
-
data = urllib.urlopen("http://login.myspace.com/index.cfm?fuseaction=login.process&: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]<form method='POST' enctype='multip art/form-data' action='http://login.myspace.c om/index.cfm?fusea ction=login.pro cess&'>
<input type="text" name="email" >
<input type="password" name="password" >
<input type="submit" value="Login"/>[/HTML]
Please help i was thinking maybe the site did browser sniffing and only allowed certain types. i dont know.
bartonc 6,596
Recognized Expert Expert
Get ClientCookie from http://wwwsearch.sourceforge.net/ClientCookie/
Inside the ClientCookie-x.x.x directory, you will find a directory called ClientCookie. Copy it to C:\Python2x\Lib \site-packages.
Change youremail, yourpassword, and anyfriendid in the following code: - import urllib
-
import urllib2
-
import ClientCookie
-
-
params = urllib.urlencode({'email':'youremail','password':'yourpassword'})
-
request = urllib2.Request("http://login.myspace.com/index.cfm?fuseaction=login.process&",params)
-
response = urllib2.urlopen(request)
-
c = ClientCookie.Cookies()
-
c.extract_cookies(response,request)
-
request2 = urllib2.Request("http://comment.myspace.com/index.cfm?fuseaction=user.viewComments&friendID=anyfriendid")
-
c.add_cookie_header(request2)
-
url2 = urllib2.urlopen(request2)
This loads (as an example) the View All Comments page of the user with anyfriendid--something you must be logged in to do. If you wish to do something else, it should be easy to infer how.
There is great info here for our members. Thank you for taking the time to post. I hope that you stick around, ask some, answer some, or just post some code that you are working on.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Richard Shea |
last post by:
Hi - I'm new to Python. I've been trying to use URLLIB and the 'tidy'
function (part of the mx.tidy package). There's one thing I'm having
real difficulties understanding. When I did this ...
finA= urllib.urlopen('http://www.python.org/')
foutA=open('C:\\testout.html','w')
tidy(finA,foutA,None)
I get ...
|
by: Haim Ashkenazi |
last post by:
Hi
I'm writing a script that uses urllib on win98. until now I used python
2.3.x (x < 4) and it worked ok. I re-installed windows and installed
python 2.3.4 and now I get an error when trying to open a url "no host
given":
Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32
Type "copyright", "credits" or "license()" for more...
|
by: Stuart McGraw |
last post by:
I just spent a $*#@!*&^&% hour registering at ^$#@#%^
Sourceforce and trying to submit a Python bug report
but it still won't let me. I give up. Maybe someone who
cares will see this post, or maybe it will save time for
someone else who runs into this problem...
================================================
Environment:
- Microsoft...
|
by: John Hunter |
last post by:
I have a test script below which I use to fetch urls into strings,
either over https or http. When over https, I use m2crypto.urllib and
when over http I use the standard urllib. Whenever, I import sockets
and setdefaulttimeout, however, using m2crypto.urllib tends to cause a
http.BadStatusLine to be raised, even if the timeout is set to be...
|
by: Tigerhillside |
last post by:
I forgot I had a "real" newsreader available. So here is the
question you will see "soon" when google decides to post my other
question.
I have a server side script that takes a user's input in a form,
packages it, and sends it on to an external server. The external
server will then send back the response via http to my server
script....
| |
by: evanpmeth |
last post by:
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 =...
|
by: supercooper |
last post by:
I am downloading images using the script below. Sometimes it will go
for 10 mins, sometimes 2 hours before timing out with the following
error:
Traceback (most recent call last):
File "ftp_20070326_Downloads_cooperc_FetchLibreMapProjectDRGs.py",
line 108, i
n ?
urllib.urlretrieve(fullurl, localfile)
File "C:\Python24\lib\urllib.py", line...
|
by: Adrian Smith |
last post by:
I'm trying to use urllib2 to download a page (I'd rather use urllib,
but I need to change the User-Agent header to look like a browser or
G**gle won't send it to me, the big meanies). The following (pinched
from Dive Into Python) seems to work perfectly in Idle, but falls at
the final hurdle when run as a cgi script - can anyone suggest...
|
by: chrispoliquin |
last post by:
Hi,
I have a small Python script to fetch some pages from the internet.
There are a lot of pages and I am looping through them and then
downloading the page using urlretrieve() in the urllib module.
The problem is that after 110 pages or so the script sort of hangs and
then I get the following traceback:
Traceback (most recent call...
|
by: K |
last post by:
Hello everyone,
I understand that urllib and urllib2 serve as really simple page
request libraries. I was wondering if there is a library out there
that can get the HTTP requests for a given page.
Example:
URL: http://www.google.com/test.html
Something like: urllib.urlopen('http://www.google.com/
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |