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 3201
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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.
| |