2016年8月31日 星期三

python3 selenium 移動滑鼠到 element 範例 (hover)

使用 selenium 時,有點要被 click 的元件,可能要先將滑鼠 hover 到某個元件上才會顯示出來
可以這樣寫:
假設我們要切換幣別為 USD 但該網站設計,必需先移動到 #currency 元件上  #usd 選項才會出現。

from selenium.webdriver.common.action_chains import ActionChains
eleCurrency = self.driver.find_element_by_css_selector("#currency")
eleUsd = self.driver.find_element_by_css_selector("#usd")
actHoverThenClick = ActionChains(seleniumDriverInstance)
actHoverThenClick.move_to_element(eleCurrency).move_to_element(eleUsd).click().perform()

2016年8月13日 星期六

python3 在 ubuntu 下安裝 lxml 模組

sudo apt-get install libxml2-dev
sudo apt-get install libxslt1-dev
python3 -m pip install lxml

python3 zipfile 解壓縮 zip 檔

from zipfile import ZipFile

with ZipFile("z.zip", "r") as zipFile:
    zipFile.extract("file_path_in_zip.xml", "folder_path_to_extract")

python3 使用 urllib 執行登入範例

無法查看此摘要。請 按這裡查看文章。