sockets
Fredrik Lundh
fredrik at pythonware.com
Fri Jan 20 02:44:11 EST 2006
archana sambandam wrote:
> the following code works perfectly
> import socket, sys
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect(("www.python.org", 80))
> s.send("GET")
> while 1:
> buf = s.recv(1000)
> if not buf:
> break
> sys.stdout.write(buf)
> s.close()
>
> but the following code does not work
>
> import socket, sys
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect(("http://www.google.co.in/search?hl=en&q=india&meta=", 80))
> s.send("GET")
> while 1:
> buf = s.recv(1000)
> if not buf:
> break
> sys.stdout.write(buf)
> s.close()
>
> the given url is the google search url for the string india.
> can u suggest some way to access the google search result page
> through SOCKETS.
>>> import urllib
>>> help(urllib)
but this won't help; using scripts to scrape the google search page is
a violation of their TOS. for a proper way to do it, see:
http://www.google.com/apis/
or use yahoo's search service, which is a lot easier to use:
http://developer.yahoo.net/search/index.html
http://developer.yahoo.net/search/web/V1/webSearch.html
</F>
More information about the Python-list
mailing list