import urllib.request
import urllib.parse
import re

#后期应对网页内容用正则表达式进行提取

word = input('输入你想搜索的内容:')
# word = '啤酒瓶'
url = 'http://lajifenleiapp.com/sk/'
#参数写为一个字典(相当于数组)
data = {
    'sk':word,
}
headers={

        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',

}
#对word进行 urlencode解码,将啤酒瓶转为%E5%95%A4%E9%85%92%E7%93%B6
query_string = urllib.parse.urlencode(data)
#python中字符串自带的split方法一次只能使用一个字符对字符串进行分割,但是python的正则模块则可以实现多个字符分割
#对  sk=%E5%95%A4%E9%85%92%E7%93%B6 进行多字符分割
arr=re.split('[=]', query_string)
#将字符存入列表arr,并对url进行拼接
url = url + arr[1]

request = urllib.request.Request(url=url,headers = headers)
response = urllib.request.urlopen(request)
print(response.read().decode())