from selenium import webdriver import time #import networkx as nx #import dataset #import pickle #import codecs from selenium.webdriver.common.keys import Keys import sys import os import time import re class JBrowser: def __init__(self): if os.name=='nt': os.chdir("C:\\Program Files\\Google\\Chrome\\Application\\") 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('--headless') if os.name=='nt': option.add_argument("--user-data-dir='C:\\Users\\jared\\AppData\\Local\\Google\\Chrome\\User Data\\"+self.profilepath+"\\'") else: option.add_argument("--user-data-dir="+self.profilepath) option.add_argument('--profile-directory="Profile 1"') self.option=option driver = webdriver.Chrome(options=option) self.driver=driver # executor_url = driver.command_executor._url # session_id = driver.session_id 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