Skip to content

Instantly share code, notes, and snippets.

View python012's full-sized avatar

Reed Xia python012

View GitHub Profile
@python012
python012 / vpn_monitor_v3.py
Created November 16, 2018 11:25
new version, work with python 3.6
#coding: utf-8
import smtplib
import config
import urllib.request as urllib2
import time
import base64
last_email_sent_time = None
error_info = None
@python012
python012 / vpn_monitor.py
Created November 19, 2018 11:36
add logging function
#coding: utf-8
#author: Reed Xia([email protected])
import smtplib
import config
import requests
import time
import base64
import sys
@python012
python012 / pretty_print_xml.py
Last active August 19, 2019 02:47
pretty print xml node, work well with Chinese xml doc
from lxml import etree
import xml.dom.minidom as mmd
xml_root = etree.parse(xml_fiel_path, etree.XMLParser())
def print_xml(xml_root):
s = etree.tostring(xml).decode('utf-8')
urgly_xml = ''.join(s.split())
good_xml = mmd.parseString(urgly_xml)
print(good_xml.toprettyxml(indent=' ',))
python3 -m venv ./venv
source ./venv/bin/activate
pip3 install -r requirements.txt
pytest -vs --color=yes --disable-warnings --junitxml=result.xml --suppress-tests-failed-exit-code
@python012
python012 / WaitForMultipleElementsAsync.java
Created June 26, 2023 08:04
使用Java 8中提供的CompletableFuture来实现异步等待多个Web元素的功能。下面是一个可能的解决方案
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;