批量下载matplotlib.pyplot.subplots页面实例源码的python脚本

来源:互联网 发布:知吾煮抗摔玻璃保鲜盒 编辑:程序博客网 时间:2024/05/29 18:08

matplotlib实例网页:

http://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.subplots.html#matplotlib.pyplot.subplots


Examples using matplotlib.pyplot.subplots模块:


单个实例页面:



批量下载源码脚本,基于selenium:

getUrlList.py

获取单个实例url页面
#coding=utf8import urllib2,redef getUrlList():    try:        url="http://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.subplots.html#matplotlib.pyplot.subplots"            matutl="http://matplotlib.org/devdocs/gallery/"        pageContent=urllib2.urlopen(url).read()        if pageContent:            linkList=re.findall('class="reference internal" href="../../gallery/(.*?)"><span class="std std-ref">(.*?)</span></a>', pageContent, re.S)             charList=[matutl+var[0] for var in linkList if len(linkList)>0]            return charList    except Exception,e:        print "Create UrlList Error:",e


getMatpoltDemo.py

批量下载matplotlib.pyplot实例源码脚本
#coding=utf8 from selenium import webdriverfrom getUrlList import getUrlListimport timeurlList=getUrlList()driver=webdriver.Chrome()        for url in getUrlList():        driver.maximize_window()    driver.get(url)    js="var q=document.body.scrollTop=200000"    driver.execute_script(js)    downLoadBtnList=driver.find_elements_by_partial_link_text('Download')        if len(downLoadBtnList)>0:        for downLoad in downLoadBtnList:            downLoad.click()    time.sleep(3)driver.close()