fix the error caused by url encoding
This commit is contained in:
parent
0edbcf404d
commit
2c08a02206
|
|
@ -4,6 +4,7 @@ import os
|
|||
import platform
|
||||
import sqlite3
|
||||
import time
|
||||
from urllib.parse import unquote
|
||||
from typing import Dict, Any, List
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
|
|
@ -985,6 +986,7 @@ def get_active_tab_html_parse(env, config: Dict[str, Any]):
|
|||
"""
|
||||
active_tab_url = get_active_url_from_accessTree(env, config)
|
||||
if not isinstance(active_tab_url, str):
|
||||
logger.error("active_tab_url is not a string")
|
||||
return None
|
||||
host = env.vm_ip
|
||||
port = 9222 # fixme: this port is hard-coded, need to be changed from config file
|
||||
|
|
@ -1017,12 +1019,14 @@ def get_active_tab_html_parse(env, config: Dict[str, Any]):
|
|||
for context in browser.contexts:
|
||||
for page in context.pages:
|
||||
page.wait_for_load_state("networkidle")
|
||||
if page.url == active_tab_url:
|
||||
# the accTree and playwright can get encoding(percent-encoding) characters, we need to convert them to normal characters
|
||||
if unquote(page.url) == unquote(active_tab_url):
|
||||
target_page = page
|
||||
print("tartget page url: ", target_page.url)
|
||||
print("tartget page title: ", target_page.title())
|
||||
print("\33[32mtartget page url: ", target_page.url, "\33[0m")
|
||||
print("\33[32mtartget page title: ", target_page.title(), "\33[0m")
|
||||
break
|
||||
if target_page is None:
|
||||
logger.error("Your tab is not the target tab.")
|
||||
return {}
|
||||
return_json = {}
|
||||
if config["category"] == "class":
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@
|
|||
"type": "rule",
|
||||
"rules":{
|
||||
"expected": {
|
||||
"locationName": "Zurich Airport",
|
||||
"dropLocationName": "Zurich Airport",
|
||||
"locationName": "Zürich",
|
||||
"dropLocationName": "Zürich",
|
||||
"filterCriteria_carCategory": "large",
|
||||
"filterCriteria_sortBy": "PRICE"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
"rules":{
|
||||
"expected": {
|
||||
"q": "drip coffee maker",
|
||||
"tbs": "mr:1,price:1,ppr_min:25,ppr_max:60,pdtr0:1825161|1825162"
|
||||
"tbs": "mr:1,price:1,ppr_min:25,ppr_max:60,sales:1,pdtr0:1825161|1825162"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue