百度搜索引擎接口

# -*- coding:utf - 8 -*-
import urllib
import urllib2

url = "http://www.baidu.com/s"
keyword = raw_input("請輸入需要查詢的內容:")
wd = {"wd":keyword}

headers = {"User-Agent":"Mozilla"}

wd = urllib.urlencode(wd)

fullurl = url + "?" + wd

request = urllib2.Request(fullurl,headers = headers)

reponse = urllib2.urlopen(request)

print response.read()

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐