Skip to content

Instantly share code, notes, and snippets.

View Nachtjagdgeschwader's full-sized avatar

Oleh Ivanov Nachtjagdgeschwader

View GitHub Profile
from telethon import TelegramClient, events, sync
from telethon.tl.types import DocumentAttributeVideo
api_id = yourAPIIDInteger
api_hash = yourAPIhashString
client = TelegramClient('session_name', api_id, api_hash)
client.start()
ids=[]
firstnames=[]
lastnames=[]
@Nachtjagdgeschwader
Nachtjagdgeschwader / CookiesSave.py
Last active September 17, 2022 18:44
Save cookies from Chrome browser to a local file
from selenium import webdriver
import os
from selenium.webdriver.chrome.options import Options
import pickle
foldertosavecookie="S:\\Users\Oleh\..."
options = Options()
options.add_argument("--no-sandbox")
dr = webdriver.Chrome('C:\\pathtodriver\chromedriver.exe',
options=options)
@Nachtjagdgeschwader
Nachtjagdgeschwader / facebook_search_RSelenium.R
Last active April 10, 2017 12:37
Save data ("URL","Date","Original Text","SharedText") about Facebook posts found by keyword with RSelenium and PhantomJS
install.packages("devtools")
library(devtools)
install_github("ropensci/RSelenium")
library(RSelenium)
psPath <- "S:/Path to PhantomJS folder/phantomjs-2.1.1-windows/bin/phantomjs.exe"
pJS <- phantom(pjs_cmd = psPath)
remDr <- remoteDriver(browserName = "phantomjs")
remDr$open()
loginURL <- 'https://www.facebook.com/login.php'
remDr$navigate(loginURL)
@Nachtjagdgeschwader
Nachtjagdgeschwader / selenium_facebook_search.py
Created April 9, 2017 19:10
Save data about Facebook posts: "Date and time", 'User', 'Text', 'Reactions', 'Shares', 'Comments', 'URL' using general search by keyword
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.common.keys import Keys
from urllib import parse
import re
from time import sleep
from datetime import datetime
@Nachtjagdgeschwader
Nachtjagdgeschwader / Get_info_from_YT_videos.R
Created April 6, 2017 20:45
Collect information about YouTube videos: Date created, Author (Channel Name), Author (Channel) URL, Title, Description, Likes, Dislikes, Number of Views, Number of Comments
library(RSelenium)
psPath <-
"C:/*/phantomjs.exe"
pJS <- phantom(pjs_cmd = psPath)
remDr <- remoteDriver(browserName = "phantomjs")
remDr$open()
# For more details of the initial configuration and
# some commands used below see
# https://gist.github.com/Nachtjagdgeschwader/e0775141c2171f769b8939006ba9624b
URLs <-
@Nachtjagdgeschwader
Nachtjagdgeschwader / Youtube_search_results.R
Created April 6, 2017 20:27
Save video links from YouTube search results using R, RSelenium and PhantomJS
# First, you need to download PhantomJS headless WebKit from here http://phantomjs.org/download.html
# and extract it to a desired folder
install.packages("RSelenium")
library(RSelenium)
# installing and running the RSelenium package which we will use for driving
# the PhantomJS WebKit
psPath <-
"C:/*/phantomjs-2.1.1-windows/bin/phantomjs.exe"
# provide the full path to phantomjs.exe on your harddrive
pJS <- phantom(pjs_cmd = psPath)