コード例 #1
0
class GetInfoFromZhihu:
    from tools import Tools

    tools = Tools()
    driver = tools.init_web_driver()

    driver = tools.login(driver=driver)

    driver = tools.click_more(driver=driver)

    titlelist = driver.find_elements_by_css_selector(
        '#zh-profile-activity-page-list > div')
    # zh-profile-activity-page-list > div:nth-child(1)
    # zh-profile-activity-page-list > div:nth-child(17) > div
    # titlelist = driver.find_elements_by_css_selector('#zh-profile-activity-page-list > div:nth-child(1) > div.zm-profile-section-main.zm-profile-section-activity-main.zm-profile-activity-page-item-main')
    print titlelist
    resultlist = []
    for elem in titlelist:

        print '++++' + elem.get_attribute('outerHTML').encode(
            'utf-8').strip() + "++++++"
        elemHTML = elem.get_attribute('outerHTML').encode('utf-8').strip()

        # zh-profile-activity-page-list > div:nth-child(5)
        actionType = tools.found_action_type(elemHTML=elemHTML)

        context = tools.get_context(elem)
        result = [actionType, context]
        resultlist.append(result)

    tools.write_to_file(resultlist)
    # print result + '\n\n\n\n\n\n\n'
    # source_code = driver.page_source
    driver.close()
コード例 #2
0
    def OnCyLoginBtnButton(self, event):
        if self.cyLoginEmailTxt.GetValue() == "" or self.cyLoginPasswordTxt.GetValue() == "":
            dlg = wx.MessageDialog(self, 'Cy 로그인 정보를 입력하세요.', '알림', wx.OK | wx.ICON_ERROR)
            try:
                result = dlg.ShowModal()
            finally:
                dlg.Destroy()
                return


        # 로그인 프로세스
        tools.setButtonState(self, self.STATE_NOWLOGING)
        self.folderList = tools.login(self)

        if self.folderList == False:
            dlg = wx.MessageDialog(self, self.mainStatusBar.GetLabel(), '로그인 중 오류가 발생하였습니다.', wx.OK | wx.ICON_ERROR)
            try:
                result = dlg.ShowModal()
            finally:
                dlg.Destroy()
                tools.setButtonState(self, self.STATE_INIT)
                return
        elif self.folderList == []:
            return



        tools.initChkListBox(self)

        tools.setButtonState(self, self.STATE_LOGGED)
        self.isRunning = False

        #----------------- 로그인 성공------------------
        self.mainStatusBar.SetLabel("싸이 로그인 성공")



        event.Skip()
コード例 #3
0
#!/usr/bin/env python2

import tools
    
tools.ABS_DATA_PATH = "../"
    
tools.login("kevin", "")
exit()
tools.get_a_theme(5, "Martinique")
theme = None
tools.get_a_theme(4, "Vayrac")
theme = None
tools.get_a_theme(11, "Mariage")

tools.print_error_report()
コード例 #4
0
ファイル: git_bisect.py プロジェクト: wazari972/WebAlbums
#!/usr/bin/env python2

import tools

tools.login("kevin", "",  get_xslt=False, parse_and_transform=False, do_static=False)
tools.get_choix(1, "Root", want_static=False, want_background=False, parse_and_transform=False)
tools.get_a_page("Database?action=TRUNK", save=False, parse_and_transform=False)
page = tools.get_a_page("Database?action=IMPORT", save=False, parse_and_transform=False)
correct = "Export OK" in page

print "Correct ? %s" % correct
exit(0 if correct else 1)


コード例 #5
0
ファイル: benchmark.py プロジェクト: wazari972/WebAlbums
def treat(xml, url, name):
    if xml.find("*/exception") is not None:
        raise Exception (xml.find("*/exception").text)
    return False

def fail(e, url, name, response, content):
    import pdb;pdb.set_trace()
    pass

tools.callback = treat
tools.fail = fail

def compute(action, mode):
    tools.get_a_page("Benchmark?action=%s&mode=%s" % (action, mode))
    
    
tools.login("kevin", "", save_index=False, get_xslt=False, do_static=False)
tools.get_choix(5, "Martinique", want_static=False, want_background=False)

with open("benchmark.log", "a+") as f:
    f.write("------------- x%d\n" % REPEAT)

action = "TAGS"
for mode in ("TAG_USED", "TAG_NUSED", "TAG_ALL", "TAG_NEVER", "TAG_NEVER_EVER", "TAG_GEO"):
    time = timeit.Timer((lambda:compute(action, mode))).timeit(REPEAT)/REPEAT

    with open("benchmark.log", "a+") as f:
        string = "Action: %s, Mode %s, %s" % (action, mode, time)
        print string
        f.write(string+"\n")
        
コード例 #6
0
spam_r = spam_info()

# DRIVER CONFIGS AND DECLARATIONS
if platform.system().lower() == 'linux':
    options = webdriver.ChromeOptions()
    options.add_argument('--user-data-dir=./User_Data')
    options.add_argument("--disable-notifications")
    driver = webdriver.Chrome('chromedriver', options=options)
    wait = WebDriverWait(driver, 40)

if "./User_Data" not in files:

    # login_inf = login_info()
    login(driver,
          wait,
          e_co,
          By,
          username=login_inf['username'],
          password=login_inf['password'])
else:
    pass
if '.txt' in spam_r['contact']:
    with open(spam_r['contact'], 'r') as listo:
        data = listo.read()
        list_of_contacts = data.split('\n')
    print(list_of_contacts)

    spam(driver,
         wait,
         e_co,
         By,
         count=spam_r['count'],
コード例 #7
0
ファイル: main.py プロジェクト: c-Monster/newMembers
def main():

    cprint('Starting LDS Tools Automator...', 'green', attrs=['bold'])

    cprint('\tFetching data from Google Sheets...', 'cyan')

    try:
        values = data.get_data()
    except ValueError:
        cprint('Error: no data in spreadsheet!', 'red', attrs=['bold'])

    members = data.parse_data(values)
    decoded = json.loads(members)

    cprint('\tPulling records...', 'cyan')
    username = raw_input(colored('\tLDS Username: '******'yellow'))
    password = getpass.getpass(colored('\tLDS Password: '******'yellow'))

    session = requests.session()
    credentials = tools.login(session, username, password)

    mrns = []
    for member in decoded:

        try:
            result = records.pull(member, credentials, session)
            mrns.append(result)
            cprint('\tsuccess!', 'green')

        except AssertionError:
            result = {'error': 'non-200 response', 'row': member['id']}
            cprint('\terror', 'red', attrs=['bold'])
        except (ValueError, KeyError, TypeError):
            result = {'error': 'unable to parse JSON', 'row': member['id']}
            cprint('\terror', 'red', attrs=['bold'])

        row = data.build_pulled_row(result)
        data.update_row(row, result['row'])

    cprint('\tFetching former bishops...', 'cyan')

    count = 0
    for member in mrns:

        try:
            result = bishops.fetch(member, credentials, session)
            cprint('\tsuccess!', 'green')
            count += 1

        except AssertionError:
            result = {'error': 'non-200 response', 'row': member['row']}
            cprint('\terror', 'red', attrs=['bold'])

        except (ValueError, KeyError, TypeError):
            result = {'error': 'unable to parse JSON', 'row': member['row']}
            cprint('\terror', 'red', attrs=['bold'])

        row = data.build_bishop_row(result)
        data.update_row(row, result['row'])

    msg = 'moved %d records' % len(mrns)
    cprint(msg, 'green', attrs=['bold'])
    msg = 'found %d bishops' % count
    cprint(msg, 'green', attrs=['bold'])
コード例 #8
0
ファイル: taobao.py プロジェクト: lidachuan211/clue
for line in file_obj.readlines():
    current_page = line
file_obj.close()

search_url = 'https://shopsearch.taobao.com/search?app=shopsearch&commend=all&q=KEY_WORD&search_type=shop&loc=%E4%B8%8A%E6%B5%B7&isb=1'
'''begin'''
#经过浏览器设置
chrome_options = webdriver.ChromeOptions()
# PROXY = "121.43.189.255:84712394"
# chrome_options.add_argument('--proxy-server=%s' % PROXY)
# chrome_options.add_experimental_option("prefs",{"profile.managed_default_content_settings.images":2})
dr = webdriver.Chrome(
    executable_path=
    "C:\Users\Administrator\Downloads\chromedriver_win32\chromedriver.exe",
    chrome_options=chrome_options)
tools.login(dr, user, password)
main_handler = dr.current_window_handle

if current_page == '':  #如果不存在则从搜索进入
    dr.get(search_url.replace('KEY_WORD', top))
    tools.append(PAGE, 'w', dr.current_url)  #保存url
else:
    dr.get(current_page)
pack = {'class': top}
index = 0
while True:
    tools.scrollToEnd(dr)  #滚动到网页末尾
    time.sleep(1)
    shops = dr.find_elements_by_xpath(
        '//a[@class="shop-name J_shop_name"]')  #获取所有shop的链接url
    for shop in shops:
コード例 #9
0
def compute():
    tools.login("kevin", "", save_index=False, do_static=DO_STATIC)
    tools.get_a_theme(5, "Martinique", want_static=False, want_background=False)
コード例 #10
0
                        default=1)
    args = parser.parse_args()
    args.streaming = args.data_portal_type == 'Streaming'
    if not args.streaming:
        args.cmd_args = {'Master': ["/app/deploy/scripts/rsa_psi/run_psi_data_join_master.sh"],
                         'Worker': ["/app/deploy/scripts/rsa_psi/run_psi_data_join_worker.sh"]}
        if args.rsa_key_pem is not None:
            args.psi_extras = [{"name": "RSA_KEY_PEM", "value": args.rsa_key_pem}]
        elif args.rsa_key_path is not None:
            args.psi_extras = [{"name": "RSA_KEY_PATH", "value": args.rsa_key_path}]
        else:
            raise Exception('Either RSA_KEY_PEN or RSA_KEY_PATH must be provided when using PSI.')
        args.psi_extras.append({"name": "SIGN_RPC_TIMEOUT_MS", "value": "128000"})

    args.url = args.url.strip().rstrip('/') + '/api/v' + str(args.api_version)
    cookie = login(args)
    federation_json, suffix = build_federation_json(args)
    federation_id, federation_name = request_and_response(args=args,
                                                          url=args.url + '/federations',
                                                          json_data=federation_json,
                                                          cookies=cookie,
                                                          name_suffix=suffix)

    raw_data_json, suffix = build_raw_data(args, federation_id, 'template_json/template_raw_data.json')
    raw_data_id, raw_data_name = request_and_response(args=args,
                                                      url=args.url + '/raw_data',
                                                      json_data=raw_data_json,
                                                      cookies=cookie,
                                                      name_suffix=suffix)
    requests.post(url=args.url + '/raw_data/' + str(raw_data_id) + '/submit', cookies=cookie)
コード例 #11
0
    def run(self):
        like_count = 0
        # hashtags_dict_analysis = {'searched_hashtags': {}} #TODO

        # Forbidden hashtags
        forbidden = tools.load_json(
            os.path.join(os.getcwd(), 'forbidden_hashtags.json'))
        forbidden = [str(i) for i in forbidden['hashtags']]

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.implicitly_wait(5)

        url = 'https://www.instagram.com/?hl=en'
        driver.get(url)

        # Access to log in page
        driver.find_element_by_xpath(
            '//*[@id="react-root"]/section/main/article/div[2]/div[2]/p/a'
        ).click()
        driver.implicitly_wait(5)
        # Log in task
        log = tools.load_json(os.path.join(os.getcwd(), 'info.json'))
        tools.login(driver, log)
        driver.implicitly_wait(5)

        # Search bar
        while True:  #loop pour pick le hashtag randomly
            like_limit = random.randint(25, self.max_like_per_round)
            hashtag = random.choice(log['search'])
            # hashtags_dict_analysis['searched_hashtags'][hashtag] = {}

            search = driver.find_element_by_css_selector(
                'input[placeholder="Search"]')  # find Search bar
            search.send_keys(hashtag)
            driver.implicitly_wait(5)

            # Click on first link
            driver.find_element_by_xpath(
                '//*[@id="react-root"]/section/nav/div[2]/div/div/div[2]/div[2]/div[2]/div/a[1]'
            ).click()
            driver.implicitly_wait(5)

            # Click on 'Load More'
            try:
                driver.execute_script(
                    "window.scrollTo(0, document.body.scrollHeight);")
                driver.find_element_by_link_text('Load more').click()
            except NoSuchElementException:
                pass

            # Click on first photo
            first_photo_xpath = '//*[@id="react-root"]/section/main/article/div[2]/div[1]/div[1]/div[1]/a'
            first_photo = driver.find_element_by_xpath(first_photo_xpath)
            ActionChains(driver).move_to_element(first_photo).perform(
            )  # remonter vers la 1er image de 'Most recent'

            count_row_scroll = 0
            # hashtag_count = 1
            try:
                row = 1
                while True:  # tant qu'on peut scroll
                    count_row_scroll += 1
                    for col in [1, 2, 3]:
                        col = str(col)
                        image_i_xpath = '//*[@id="react-root"]/section/main/article/div[2]/div[1]/div[' + str(
                            row) + ']/div[' + col + ']/a'
                        image_i = driver.find_element_by_xpath(image_i_xpath)
                        ActionChains(driver).move_to_element(image_i).perform()
                        image_i.click()

                        username_xpath = '/html/body/div[3]/div/div/div[2]/div/article/header/div[2]/div[1]/div/a'
                        username = driver.find_element_by_xpath(
                            username_xpath).get_attribute('title')
                        if 'shop' in username:  # TODO A RETRAVAILLER
                            pass
                        else:
                            caption_xpath = '/html/body/div[3]/div/div/div[2]/div/article/div[2]/div[1]/ul/li'
                            caption = driver.find_element_by_xpath(
                                caption_xpath).text

                            # Get hashtags with regex
                            # hashtags_ = re.findall(r"#(\w+)", caption)
                            # hashtags_ = list(set(hashtags_))
                            # any_in = lambda a, b: bool(set(a).intersection(b))  # intersection between 2 lists
                            # if any_in(forbidden, hashtags_):
                            #     pass
                            # else:
                            # hashtags_dict_analysis['searched_hashtags'][hashtag] = hashtags_
                            # hashtag_count += 1
                            # Follow, like
                            try:  # a mettre dans le else
                                if driver.find_element_by_xpath(
                                        "//button[contains(.,'Following')]"):
                                    print(username + 'is already followed')
                            except NoSuchElementException:
                                driver.find_element_by_xpath(
                                    "//button[contains(.,'Follow')]").click()
                                time.sleep(random.uniform(0.2, 0.8))
                                try:
                                    driver.find_element_by_xpath(
                                        "//span[contains(.,'Like')]").click()
                                    like_count += 1
                                    # hashtag_count += 1
                                except NoSuchElementException:  # if already liked [contains(., 'Unlike)]
                                    pass
                            finally:
                                time.sleep(random.uniform(0.2, 0.8))
                                driver.find_element_by_xpath(
                                    "//button[contains(.,'Close')]").click()
                                driver.implicitly_wait(5)

                    # Scroll down
                    if count_row_scroll == 4:  # 1 new load = 4 lignes de charger
                        driver.execute_script(
                            "window.scrollTo(0, document.body.scrollHeight);")
                        time.sleep(random.uniform(0.3, 0.8))
                        count_row_scroll = 0

                    row += 1

                    if like_count == like_limit:  # tous les X likes, stop
                        stop_ = random.uniform(20, 45)
                        print(time.localtime(), stop_)
                        time.sleep(60 * stop_)
                        like_limit = random.randint(25,
                                                    self.max_like_per_round)
                        print('Onto the next : %s' % (time.strftime(
                            '%d/%m/20%y_%H:%M:%S', time.localtime())))

            except NoSuchElementException:  # if no more image
                pass  # look for another hashtag in search bar

            if time.localtime()[7] == self.start[7]:  #si meme jour
                if time.localtime()[3] == self.start[3] + 10:
                    self.restart()
            else:
                self.restart()
コード例 #12
0
	except: pass
	try: os.mkdir(f'{root}/work-folder/data')
	except: pass
	try: os.mkdir(f'{root}/trash')
	except: pass

	cmd = [" "]
	tools.loadCache()
	while len(cmd):
		option = cmd.pop(0)
		try: 
			if   option=="new"	: tools.new(cmd[0])
			elif option=="open"	: tools.open_dir(cmd[0])
			elif option=="vim"	: tools.vim(*cmd)
			elif option=="view"	: tools.view(*cmd)
			elif option=="login": tools.login()
			elif option=="post"	: tools.post(*cmd)
			elif option=="clear": tools.copyTemplates()
			elif option=="check": tools.check(True, *cmd)
			elif option=="run"	: tools.check(False, *cmd)
			elif option=="save"	: tools.saveSolution(*cmd)
			elif option=="rm"	: tools.removeFile()
			elif option=="help"	: print(help_string)

		except: print(
			f"ERR: {sys.exc_info()[0]} {sys.exc_info()[1]} "+
			f"line: {sys.exc_info()[2].tb_lineno}")

		print("----------------------------------------------------")
		tools.saveCache()
		cmd = input("command: ").split()
コード例 #13
0
        "desc": "",
        "desc_format_id": 0,
        "dynamic": "",
        "interactive": 0,
        "no_reprint": 0,
        "subtitles": {
            "lan": "",
            "open": 0
        },
        "tag": "录播,%s" % uname,
        "tid": 174,
        "title": uploadName,
        "videos": [
            {
                "desc": "",
                "filename": filename,
                "title": "P1"
            }
        ]
    }
    try:
        result = video.video_submit(data, verify)
        logger.info('上传结果: %s' % (result))
    except:
        logger.error('%s[RoomID:%s]投稿失败' % (uname, roomID))
        return None

if __name__ == '__main__':
    uname, roomID, uploadName, filePath= sys.argv[1:5]
    upload(uname,roomID,uploadName,filePath,tools.login())