#
# s = '网站地图' 原始 # s1 = s.encode('utf-8') # print(s1.decode('gbk')) #res 缃戠珯鍦板浘 # s = '缃戠珯鍦板浘' 原始 # s1 = s.encode('gbk') # print(s1.decode('utf8')) #res 网站地图 # http://www.mytju.com/classcode/tools/messyCodeRecover.asp 一个解乱码网站
# 淘宝/天猫
from urllib.request import unquote url='//detail.tmall.com/item.htm?idu003d579794586729u0026ad_idu003du0026am_idu003du0026cm_idu003d140105335569ed55e27bu0026pm_idu003du0026abbucketu003d2' url1 = unquote(url) print(url1)
selenium 驱动浏览器
from selenium import webdriver from selenium.webdriver.chrome.options import Options import time chrome_option = Options() #实例化 chrome_option.add_argument('--headless') #无头 chrome_option.add_argument('--disable-gpu') #禁用gpu硬件加速器 关闭GPU显卡硬件加速办法
br = webdriver.Chrome(options=chrome_option) br.get('https://www.taobao.com') lis = br.find_elements_by_css_selector('.service-bd li') # input = br.find_element_by_id('q') # input.send_keys('iphone') # time.sleep(1) # input.clear() # input.send_keys('ipad') # btn = br.find_element_by_class_name('btn-search') # btn.click() print(lis) br.close()