|
@@ -0,0 +1,58 @@
|
|
|
+"""
|
|
|
+@author: luojunhui
|
|
|
+"""
|
|
|
+import requests
|
|
|
+
|
|
|
+
|
|
|
+def tunnel_proxies():
|
|
|
+ """
|
|
|
+ 快代理
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 隧道域名:端口号
|
|
|
+ tunnel = "q796.kdltps.com:15818"
|
|
|
+ # 用户名密码方式
|
|
|
+ username = "t17772369458618"
|
|
|
+ password = "5zqcjkmy"
|
|
|
+ proxies = {
|
|
|
+ "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel},
|
|
|
+ "https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel}
|
|
|
+ }
|
|
|
+ return proxies
|
|
|
+
|
|
|
+
|
|
|
+def get_img_list(search_title):
|
|
|
+ """
|
|
|
+ 获取图片list
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ url = "https://lab.magiconch.com/api/baidu/images"
|
|
|
+ params = {
|
|
|
+ "text": search_title,
|
|
|
+ "index": 0,
|
|
|
+ "size": 60
|
|
|
+ }
|
|
|
+ headers = {
|
|
|
+ 'accept': '*/*',
|
|
|
+ 'accept-language': 'en,zh;q=0.9,zh-CN;q=0.8',
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ 'cookie': 'Hm_lvt_f4e477c61adf5c145ce938a05611d5f0=1718784293; Hm_lpvt_f4e477c61adf5c145ce938a05611d5f0=1718784293',
|
|
|
+ 'if-none-match': 'W/"5e03-9dK2z/6rD0/7aX0R6HraLuFnLjI"',
|
|
|
+ 'priority': 'u=1, i',
|
|
|
+ 'referer': 'https://lab.magiconch.com/baidu-images/',
|
|
|
+ 'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
|
|
|
+ 'sec-ch-ua-mobile': '?0',
|
|
|
+ 'sec-ch-ua-platform': '"macOS"',
|
|
|
+ 'sec-fetch-dest': 'empty',
|
|
|
+ 'sec-fetch-mode': 'cors',
|
|
|
+ 'sec-fetch-site': 'same-origin',
|
|
|
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
|
|
|
+ }
|
|
|
+ response = requests.request("GET", url, headers=headers, params=params, proxies=tunnel_proxies())
|
|
|
+ res = response.json()
|
|
|
+ response = [i['ori'] for i in res[:15]]
|
|
|
+ return response
|
|
|
+
|
|
|
+
|
|
|
+img_list = get_img_list("破纪录!中国年龄最大的夫妻,有什么长寿秘诀?")
|
|
|
+print(img_list)
|