#encoding:utf-8
import urllib2
import urllib
import re

gjc = urllib.quote("Python") #关键词设置

#print gjc
url = "http://sug.so.360.cn/suggest?callback=suggest_so&encodein=utf-8&encodeout=utf-8&format=json&fields=word,obdata&word="+gjc #URL设置

#headers设置
headers = {    
    "GET":url,
    "Host":"sug.so.360.cn",
    "Referer":"http://www.so.com/",
    "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36",
    }

req = urllib2.Request(url)

for key in headers:
        req.add_header(key,headers[key])

html = urllib2.urlopen(req).read()
ss = re.findall("\".*?\"",html)
for item in ss:
                print item

Profeel
289 声望17 粉丝

Brilliant's everywhere.


引用和评论

0 条评论