Created
October 27, 2017 13:09
-
-
Save abeeku/2700e226bcb0614150d05709bb92e5e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from selenium import webdriver | |
import time | |
#firefoxProfile = webdriver.FirefoxProfile() | |
from bs4 import BeautifulSoup | |
import subprocess | |
import random | |
import requests | |
import os | |
#from selenium.webdriver.support import expected_conditions as EC | |
#from selenium.webdriver.support.wait import WebDriverWait | |
from selenium.webdriver.chrome.options import Options | |
## Use the driver | |
chrome_options = Options() | |
chrome_options.add_argument("--headless") | |
chrome_options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary' | |
def watch(url, seas): | |
browser =webdriver.Chrome(executable_path="./chromedriver",chrome_options=chrome_options) | |
browser.get(url) | |
browser.set_window_size(0, 0) | |
soup = BeautifulSoup(browser.page_source, "lxml") | |
browser.close() | |
vid = soup.find("video").get("src") | |
# subprocess.call(["mpv", vid, "--fs"]) | |
return vid | |
def sponge(): | |
try: | |
return spo() | |
except: | |
return spo() | |
def spo(): | |
seas = random.randint(1,9) | |
if seas == 1: | |
seasonUrl = "https://kisscartoon.cc/3028-2/" | |
elif seas == 2: | |
seasonUrl = "https://kisscartoon.cc/__trashed/" | |
else: | |
seasonUrl = "https://kisscartoon.cc/spongebob-squarepants-season-%s/" % seas | |
req = requests.get(seasonUrl) | |
sesoup = BeautifulSoup(req.text, "lxml") | |
return watch(random.choice(sesoup.find("table").find_all("a")).get("href"), seas) | |
#print ep | |
#watch(ep.get("href")) | |
#side = random.choice(['A','B']) | |
#url = "https://kisscartoon.cc/spongebob-squarepants-season-%s/season/1/episode/%s%s/"% (seas, epnun, side) | |
#url = raw_input("Enter url: ") | |
#watch(url) | |
def fill(): | |
import pickle | |
list=[] | |
for _ in range(15): | |
list.insert(len(list),spongy.sponge()) | |
with open("thelinks.txt",'wb') as f: | |
pickle.dump(list,f) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment