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 3206
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 information.
|
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 Windows 2000 Pro
|
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 very
large. All of the documents in the test script can be accessed
publicly.
Any ideas? Is...
|
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. But not the same script. And there is the rub, I don't
know how the second script can get to my user.
| |
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 = urllib.urlencode({'email' : 'a@a.com',
|
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 89, in urlretrieve
|
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
anything I may have overlooked?
request = urllib2.Request(some_URL)
request.add_header('User-Agent',...
|
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 last):
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |