Exemplo n.º 1
0
    def moneyMsg(self, ptype):

        if not self.wdriver:
            if self.isCmdMode:
                print 'used phantomjs'
                import selenium.webdriver.phantomjs.webdriver as wd
                self.wdriver = wd.WebDriver('/usr/local/bin/phantomjs')  #test
                self.wdriver.maximize_window()
            else:
                print 'used chrome'
                import selenium.webdriver.chrome.webdriver as wd
                self.wdriver = wd.WebDriver(
                    '/Users/mage/Documents/tool/cmdtool/chromedriver')  #test
                self.wdriver.maximize_window()

        hurl = ''
        if ptype == 'btc':
            hurl = 'http://btcwisdom.net'
        else:
            hurl = 'http://ltcwisdom.net'

        self.wdriver.get(hurl)

        #难度信息
        datdic = self.getDiffcultFromWeb(self.wdriver)
        return datdic
Exemplo n.º 2
0
    def runWork(self, isCmdMode=True):
        self.isCmdMode = isCmdMode
        if not self.wdriver:
            if self.isCmdMode:
                import selenium.webdriver.phantomjs.webdriver as wd
                self.wdriver = wd.WebDriver('/usr/local/bin/phantomjs')  #test
                self.wdriver.maximize_window()
                print('used phantomjs')
            else:
                # import selenium.webdriver.chrome.webdriver as  wd
                # chrome_options = wd.ChromeOptions()
                # chrome_options.add_argument('--headless')
                # chrome_options.add_argument('--disable-gpu')
                # self.wdriver = wd.WebDriver('/Users/mage/Documents/tool/cmdtool/chromedriver')       #test
                # self.wdriver.maximize_window()
                from selenium import webdriver
                chrome_options = webdriver.ChromeOptions()
                chrome_options.add_argument('--headless')
                chrome_options.add_argument('--disable-gpu')
                chrome_options.add_argument(
                    "user-agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'"
                )
                self.wdriver = webdriver.Chrome(
                    chrome_options=chrome_options,
                    executable_path=
                    '/Users/mage/Documents/tool/cmdtool/chromedriver')

        self.wdriver.get(self.mineiotaURL)

        outdic = {}

        #企业高管信息
        self.startMining(self.wdriver)  #获取高管信息
Exemplo n.º 3
0
    def setUp(self):
        # setUp is where you instantiate the selenium webdriver and loads the browser.
        User = get_user_model()

        User.objects.create_superuser(username='******',
                                      password='******',
                                      email='*****@*****.**')

        self.selenium = webdriver.WebDriver()
        self.selenium.maximize_window()
        super(AdminTestCase, self).setUp()
Exemplo n.º 4
0
    def companyMsg(self,tid,lastMd5):

        if not self.wdriver:
            if self.isCmdMode:
                print 'used phantomjs'
                import selenium.webdriver.phantomjs.webdriver as wd
                self.wdriver = wd.WebDriver('/usr/local/bin/phantomjs')       #test
                self.wdriver.maximize_window()
            else:
                print 'used chrome'
                import selenium.webdriver.chrome.webdriver as  wd
                self.wdriver = wd.WebDriver('/Users/mage/Documents/tool/cmdtool/chromedriver')       #test
                self.wdriver.maximize_window()

        hurl = 'http://basic.10jqka.com.cn/%s/news.html'%(tid)

    
        self.wdriver.get(hurl)

        #企业高管信息
        datdic = self.getGongGaoTitle(self.wdriver,lastMd5)                                                #获取高管信息
        return datdic
Exemplo n.º 5
0
    def companyMsg(self, tid):

        if not self.wdriver:
            if self.isCmdMode:
                import selenium.webdriver.phantomjs.webdriver as wd
                self.wdriver = wd.WebDriver('/usr/local/bin/phantomjs')  #test
                self.wdriver.maximize_window()
            else:
                import selenium.webdriver.chrome.webdriver as wd
                self.wdriver = wd.WebDriver(
                    '/Users/mage/Documents/tool/cmdtool/chromedriver')  #test
                self.wdriver.maximize_window()

        hurl = 'http://basic.10jqka.com.cn/%s/company.html' % (tid)

        self.wdriver.get(hurl)

        outdic = {}

        #企业高管信息
        datdic = self.getManager(self.wdriver)  #获取高管信息
        outdic['ggjs'] = datdic

        #公司详情
        companymsg = self.getCompanyMsg(self.wdriver)
        # print companymsg
        outdic['xxqk'] = companymsg

        #获取发行信息
        fxmsg = self.getPublishMsg(self.wdriver)
        # print fxmsg
        outdic['fxxg'] = fxmsg

        #获取参股企业
        outmsg = self.getSharesCompanys(self.wdriver)
        # print outmsg
        outdic['cgkggs'] = outmsg

        return outdic
Exemplo n.º 6
0
    def moneyMsg(self):

        if not self.wdriver:
            if self.isCmdMode:
                print 'used phantomjs'
                import selenium.webdriver.phantomjs.webdriver as wd
                self.wdriver = wd.WebDriver('/usr/local/bin/phantomjs')  #test
                self.wdriver.maximize_window()
            else:
                print 'used chrome'
                import selenium.webdriver.chrome.webdriver as wd
                self.wdriver = wd.WebDriver(
                    '/Users/mage/Documents/tool/cmdtool/chromedriver')  #test
                self.wdriver.maximize_window()

        self.wdriver.get(self.AllCoinURL)
        starttime = time.ctime(int(time.time()))

        #难度信息
        datdic = self.getAllCoinFromWeb(self.wdriver)
        print 'start', starttime
        print 'end', time.ctime(int(time.time()))
        return datdic
Exemplo n.º 7
0
    def runWork(self, isCmdMode=True):
        self.isCmdMode = isCmdMode
        if not self.wdriver:
            if self.isCmdMode:
                import selenium.webdriver.phantomjs.webdriver as wd
                self.wdriver = wd.WebDriver('/usr/local/bin/phantomjs')  #test
                self.wdriver.maximize_window()
                print('used phantomjs')
            else:
                # import selenium.webdriver.chrome.webdriver as  wd
                # chrome_options = wd.ChromeOptions()
                # chrome_options.add_argument('--headless')
                # chrome_options.add_argument('--disable-gpu')
                # self.wdriver = wd.WebDriver('/Users/mage/Documents/tool/cmdtool/chromedriver')       #test
                # self.wdriver.maximize_window()
                # linux上安装chrome要安装这两个库libgconf2-4 libnss3-1d
                #https://jiayi.space/post/zai-ubuntufu-wu-qi-shang-shi-yong-chrome-headless
                #chrome drvier下载:https://sites.google.com/a/chromium.org/chromedriver/downloads
                #

                from selenium import webdriver
                # from pyvirtualdisplay import Display
                # display = Display(visible=0, size=(800, 800))
                # display.start()
                # time.sleep(1)
                chrome_options = webdriver.ChromeOptions()
                chrome_options.add_argument('--headless')
                chrome_options.add_argument('--disable-gpu')
                chrome_options.add_argument(
                    "user-agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'"
                )
                self.wdriver = webdriver.Chrome(
                    chrome_options=chrome_options,
                    executable_path='/root/chrome/chromedriver')
                print('used chrome')

        self.wdriver.get(self.mineiotaURL)

        outdic = {}

        #企业高管信息
        self.startMining(self.wdriver)  #获取高管信息
Exemplo n.º 8
0
 def start(self):
     self.browser = webdriver.WebDriver()
Exemplo n.º 9
0
    # 'Accept-Encoding': "gzip, deflate, sdch, br",
    # 'Accept-Language': "zh-CN,zh;q=0.8,en;q=0.6",
    # 'Cache-Control': "no-cache",
    # 'Connection': "keep-alive",
    # 'Host': "www.baidu.com",
    # 'Pragma': "no-cache",
    # 'Upgrade-Insecure-Requests': "1",
    'User-Agent':
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
}

# # 设置请求头
for key in headers:
    webdriver.DesiredCapabilities.PHANTOMJS[
        'phantomjs.page.customHeaders.{}'.format(key)] = headers[key]
driver = webdriver.WebDriver(executable_path=phantom_path)
driver.get("https://www.baidu.com")

# file_handler = open("baidu.html","wb")
# file_handler.write(driver.page_source.encode("utf-8"))
# file_handler.close()

# api 方法
# 根据html的id查询
driver.find_element_by_id()

# 根据name属性查询,比如input元素的name
driver.find_element_by_name()  # 查询一个
driver.find_elements_by_name()  # 查询多个

# 根据class定位