Hi,
I am writing http protocol to get some data from servers. If i was
using my localhost, getting replay from local and if want access other
remote sites, i am getting error. Please reply it
My localhost client script:::
Code: ( python )
import httplib
h = httplib.HTTP('localhost',80)
h.putrequest('GET','')
h.putheader('User-Agent','Lame Tutorial Code')
h.putheader('Accept','text/html')
h.endheaders()
errcode,errmsg, headers = h.getreply()
print errcode,errmsg, headers
f = h.getfile() # Get file object for reading data
data = f.read()
print data
f.close()
the Reply getting from this::::
403 Forbidden Date: Tue, 18 Sep 2007 05:20:36 GMT
Server: Apache/2.0.52 (Red Hat)
Accept-Ranges: bytes
Content-Length: 3985
Connection: close
Content-Type: text/html; charset=UTF-8
And some Html script
If I want to access other sites:::
import httplib
h = httplib.HTTP('http://Google.com',80)
h.putrequest('GET','')
h.putheader('User-Agent','Lame Tutorial Code')
h.putheader('Accept','text/html')
h.endheaders()
errcode,errmsg, headers = h.getreply()
print errcode,errmsg, headers
f = h.getfile() # Get file object for reading data
data = f.read()
print data
f.close()
I got the error like:::
Traceback (most recent call last):
File "c.py", line 6, in ?
h.endheaders()
File "/usr/lib/python2.3/httplib.py", line 712, in endheaders
self._send_output()
File "/usr/lib/python2.3/httplib.py", line 597, in _send_output
self.send(msg)
File "/usr/lib/python2.3/httplib.py", line 564, in send
self.connect()
File "/usr/lib/python2.3/httplib.py", line 532, in connect
socket.SOCK_STREAM):
socket.gaierror: (-2, 'Name or service not known')
How can I access Remote sites using http protocol . I did'nt write
server script.
Thanks And Regards
Allavarapu 2 1870
On Sep 19, 6:10 am, welcomestocont...@gmail.com wrote:
Hi,
I am writing http protocol to get some data from servers. If i was
using my localhost, getting replay from local and if want access other
remote sites, i am getting error. Please reply it
My localhost client script:::
Code: ( python )
import httplib
h = httplib.HTTP('localhost',80)
h.putrequest('GET','')
h.putheader('User-Agent','Lame Tutorial Code')
h.putheader('Accept','text/html')
h.endheaders()
errcode,errmsg, headers = h.getreply()
print errcode,errmsg, headers
f = h.getfile() # Get file object for reading data
data = f.read()
print data
f.close()
the Reply getting from this::::
403 Forbidden Date: Tue, 18 Sep 2007 05:20:36 GMT
Server: Apache/2.0.52 (Red Hat)
Accept-Ranges: bytes
Content-Length: 3985
Connection: close
Content-Type: text/html; charset=UTF-8
And some Html script
If I want to access other sites:::
import httplib
h = httplib.HTTP('http://Google.com',80)
h.putrequest('GET','')
h.putheader('User-Agent','Lame Tutorial Code')
h.putheader('Accept','text/html')
h.endheaders()
errcode,errmsg, headers = h.getreply()
print errcode,errmsg, headers
f = h.getfile() # Get file object for reading data
data = f.read()
print data
f.close()
I got the error like:::
Traceback (most recent call last):
File "c.py", line 6, in ?
h.endheaders()
File "/usr/lib/python2.3/httplib.py", line 712, in endheaders
self._send_output()
File "/usr/lib/python2.3/httplib.py", line 597, in _send_output
self.send(msg)
File "/usr/lib/python2.3/httplib.py", line 564, in send
self.connect()
File "/usr/lib/python2.3/httplib.py", line 532, in connect
socket.SOCK_STREAM):
socket.gaierror: (-2, 'Name or service not known')
How can I access Remote sites using http protocol . I did'nt write
server script.
Thanks And Regards
Allavarapu
1. First try setting the debug level with
h.set_debuglevel(9)
2. nslookup or dig google.com
3. are you behind a firewall ?
4. why not just use urllib.urlopen ? Its a lot easier and sets up all
the headers, and yes it can do POSTs. we***************@gmail.com wrote:
h = httplib.HTTP('http://Google.com',80)
This should be:
h = httplib.HTTP('Google.com',80)
And I certainly agree with the others, check out urllib*.
Ian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: turnit \(removethis\) |
last post by:
I have a login form that uses the post method to carry the
information to the next page. The form works just fine in
ie6.0, but fails in mozilla and fails in ie5.2 on a
mac. "HTTP/1.1 400 Bad...
|
by: Justin Malloy |
last post by:
I am using the System.Net.Webclient to try and download an
XML file from a website but am receiving a HTTP protocol
error when running the DownloadFile() sub routine. I did
a HTTP trace using...
|
by: mike |
last post by:
regards:
How do I know that edition 1.0 or 1.1 the HTTP Server support?.....
Support of HTTP edition is decided by client end or server end?
Any positive suggestion is welcome.
thank you
May...
|
by: Gery D. Dorazio |
last post by:
Hi,
I am trying to create my own custom logging mechanism using an IHttpModule.
To do this I gather various information about the request and response using
the HttpRequest and HttpResponse...
|
by: Mat |
last post by:
I would like to write a client-server application which will communicate
through HTTP PROTOCOL . essentially, client will send and received xml
files.
is it possible??
I want to use http...
|
by: Bob Badger |
last post by:
Hi,
Simple question (although I guess with a complicated answer). Is HTTP
an async protocol? For instance, if I send a message to a c#
webservice via http what is the protocol actually doing?
...
|
by: Benry |
last post by:
Hi guys. I hope I can discuss Twisted here. If not, direct me to the
correct place please.
My question(s):
I'm working on a custom network protocol (application layer in TCP/IP
model) for a...
|
by: Marcus Ogden |
last post by:
Hello,
A client of ours using the Squid proxy server (version
2.5.STABLE6-3.4E.12.1) on Red Hat Enterprise Linux 4 is experiencing a
problem when running our .NET 2.0 client application, which...
|
by: welcomestocontact |
last post by:
Hi,
I am writing http protocol to get some data from servers. If i was
using my localhost, getting replay from local and if want access other
remote sites, i am getting error. Please reply it
...
|
by: Thomas Lunsford |
last post by:
I have been asked to allow one of our old-school .asp pages to support
being used as a web service. Specifically, WSDL was mentioned. I am
not an expert on this , but I have done quite a bit of...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
| |