# coding:UTF-8
import urllib.request
import urllib
import re
import time
from random import choice
iplist=['110.73.142.124','119.188.94.145','119.48.180.182']
list=["编程","前端"]
for item in list:
ip=choice(iplist)
gjc=urllib.parse.quote(item)
# gjc="集团"
# gjc=urllib.parse.quote(gjc)
# print(gjc)
url="https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd="+gjc+"&json=1&p=3&sid=18285_1460_18283_12826_18560_17001_17073_15526_11784_18081_18017&csor=2&cb=jQuery110205117536815814674_1454926196994&_=1454926197002"
headers={
"Get":url,
"Host":"sp0.baidu.com",
"Referer":"https://www.baidu.com/",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 UBrowser/5.5.10106.5 Safari/537.36"
}
proxy_support=urllib.request.ProxyHandler({'http':'http://'+ip})
opener=urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
req=urllib.request.Request(url)
for key in headers:
req.add_header(key, headers[key])
html=urllib.request.urlopen(req).read().decode('gb2312')
ss=re.findall("\"s\":\[(.*?)\]",html)
for item in ss:
pass
q=re.findall("\"(.*?)\"",item)
for item in q:
print(item)
# time.sleep(6)