工作目的
组里师兄最近遇到一个问题,他有一堆有机物化学式需要去http://www.chemspider.com这个网站上看看有没有已知的结构和物质。他的化学式太多,一个一个查肯定效率低下,于是想用代码来做这件事。我之前也是正好瞅见过其他师兄用过selenium这个软件来做浏览器的模拟,想了一下可能自己可以试试这个东西的用法,然后就造出了下面这个代码。
代码
没空写太多废话,直接上代码:
#!/bin/python3
#coding=utf-8
from selenium import webdriver
import time
import requests
#from bs4 import BeautifulSoup as bs
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
def get_result(formula_list):
#headless mode configured
ch_options = Options()
ch_options.add_argument("--headless")
#apply headless mode
driver = webdriver.Chrome(chrome_options = ch_options)
for formula in formula_list