ggrg
This commit is contained in:
38
test111.py
38
test111.py
@@ -10,6 +10,16 @@ if __name__ == '__main__':
|
||||
co = ChromiumOptions()
|
||||
co.set_local_port(9999)
|
||||
|
||||
co.set_local_port(9999)
|
||||
co.headless(False) # 先用有头模式测试,看是否还能触发
|
||||
co.incognito(False) # 避免无痕
|
||||
co.set_argument('--disable-blink-features=AutomationControlled')
|
||||
co.set_argument('--no-sandbox')
|
||||
co.set_argument('--disable-infobars')
|
||||
co.set_argument('--disable-extensions')
|
||||
co.set_argument('--start-maximized')
|
||||
co.set_user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36") # 真实 UA
|
||||
|
||||
page = ChromiumPage(addr_or_opts=co)
|
||||
|
||||
# 读取 Excel 文件
|
||||
@@ -36,17 +46,19 @@ if __name__ == '__main__':
|
||||
# 解析查询参数为字典
|
||||
param_dict = parse_qs(query_params)
|
||||
|
||||
a = time.time()
|
||||
tab = page.new_tab()
|
||||
tab.listen.start("shopee.tw/api/v4/pdp/get_pc")
|
||||
tab.get(f"https://shopee.tw/product/{param_dict['shop_id'][0]}/{param_dict['item_id'][0]}")
|
||||
res = tab.listen.wait(timeout=15)
|
||||
print(res.response.body)
|
||||
if res.response.body.get("data", {}).get("item", {}):
|
||||
n += 1
|
||||
n1 += time.time() - a
|
||||
print(param_dict['shop_id'][0])
|
||||
print(param_dict['item_id'][0])
|
||||
|
||||
logger.info(f"成功第{n}个,耗时{time.time() - a}秒")
|
||||
logger.success(f"成功第{n}个,一共耗时{n1}秒")
|
||||
|
||||
tab.close()
|
||||
# a = time.time()
|
||||
# tab = page.new_tab()
|
||||
# tab.listen.start("shopee.tw/api/v4/pdp/get_pc")
|
||||
# tab.get(f"https://shopee.tw/product/{param_dict['shop_id'][0]}/{param_dict['item_id'][0]}")
|
||||
# res = tab.listen.wait(timeout=15)
|
||||
# print(res.response.body)
|
||||
# if res.response.body.get("data", {}).get("item", {}):
|
||||
# n += 1
|
||||
# n1 += time.time() - a
|
||||
# # https: // shopee.tw / api / v4 / pdp / get_pc?item_id = 22577587881 & shop_id = 1014505717 & tz_offset_minutes = 480 & detail_level = 0 & logger.info(f"成功第{n}个,耗时{time.time() - a}秒")
|
||||
# logger.success(f"成功第{n}个,一共耗时{n1}秒")
|
||||
#
|
||||
# tab.close()
|
||||
|
||||
Reference in New Issue
Block a user