# -*- coding: cp936 -*-
import urllib2,urllib,sys,io
"""
使用GET在百度搜索引擎上查询
此例演示如何生成GET串,并进行请求.
"""
url = "http://www.baidu.com/s"
search = [('w','codemo')]
getString = url + "?" + urllib.urlencode(search)
req = urllib2.Request(getString)
fd = urllib2.urlopen(req)
baiduResponse=""
while 1:
data= fd.read(1024)
if not len(data):
break
baiduResponse+=data
fobj=open("baidu.html",'w')
fobj.write(baiduResponse)
fobj.close()
python get
最新推荐文章于 2024-05-10 16:20:06 发布