123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- from selenium import webdriver
- import time
- import pickle
- import codecs
- from selenium.webdriver.common.keys import Keys
- import sys
- import os
- import time
- import re
- import json
- import configparser, os
- from os.path import expanduser
- class JBrowser:
- def __init__(self):
- os.chdir("C:\\Program Files\\Google\\Chrome\\Application\\")
- home = expanduser("~")
- print(home)
- config = configparser.ConfigParser()
- content=config.read_file(open(home+'\\test.cfg'))
- print(content)
- print(config['DEFAULT'])
- print(config.sections())
- self.userdir=config['DEFAULT'].get('userdir')
- def set_profile_path(self,profilepath):
- self.profilepath=profilepath
- option = webdriver.ChromeOptions()
- option.add_argument('--disable-web-security')
- option.add_argument('--allow-running-insecure-content')
-
- option.add_argument("--user-data-dir="+self.userdir+profilepath+"\\")
- self.option=option
- driver = webdriver.Chrome(options=option)
- self.driver=driver
- def scrolling(self,pgnum):
- ub = self.driver.find_element_by_css_selector('body')
- for i in range(pgnum):
- ub.send_keys(Keys.PAGE_DOWN)
- if pgnum>1:
- time.sleep(0.5)
- def get(self,url):
- self.driver.get(url)
- def get_driver(self):
- return self.driver
|