[python]代码库
import requests
n = 1
# 初始化程序
def sou_suo(e):
while True:
inp = input('选择搜素引擎:1.百度,2.搜狗,3.360,4.bing')
if inp == '1':
url = 'https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd={}'
elif inp == '2':
url = 'https://www.sogou.com/web?query={}'
elif inp == '3':
url = 'https://www.so.com/s?ie=utf-8&src=hao_360so_b_cube&shb=1&hsid=058da16de5cb6f03&ssid=&q={}'
elif inp == '4':
url = 'https://cn.bing.com/search?q={}'
else:
print('输入错误!')
t = input('输入要搜索的内容:')
w = requests.get(url.format(t), headers=headers)
print(w.url)
a = input('是否继续搜索?1继续,2不继续')
for i in range(n):
if a == '1':
e = 1
continue
elif a == '1':
e = 2
break
else:
print('输入错误!')
e = 3
if e == 1:
continue
elif e == 2:
break
elif e == 3:
continue
# 初始化访问配置
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Mobile Safari/537.36 Edg/97.0.1072.69'
}
# 主程序
sou_suo(e=0)