环境配置
选择python+selenium+wget+Safari的环境来下载文件,本来期望使用phantomjs,但使用时点击出的链接网页为空白网页,无法下载文件。
使用Safari时遇到的错误:selenium.common.exceptions.WebDriverException: Message: Could not create a session: You must enable the 'Allow Remote Automation' option in Safari's Develop menu to control Safari via WebDriver.解决方式需要在Safari=>开发中选上"允许远程自动化"。
原始代码
#!/usr/bin/python
# -*- coding: utf-8 -*-
__metaclass__ = type
import io
from selenium import webdriver
import time
import sys
import re
import os
from selenium.webdriver.common.keys import Keys
import wget
import urllib
from urllib import request
import shutil
#from selenium.webdriver import ActionChains
#from selenium.webdriver.common.keys import Keys
'''class: DownloadFromCninfo'''
class DownloadFromCninfo(object):
def __init__(self,stockNumberStr,maxNumber=10000):
self.stockNumber = stockNumberStr
#选择浏览器
self.RecordDownloadIndex = 1
self.maxDownloadNumber = maxNumber
self.driver &