Last active
July 17, 2017 14:16
-
-
Save mlouielu/80eb97738e889a2d6b744e793cb5f082 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/env python | |
# -*- coding:utf8 -*- | |
import json | |
import os | |
import re | |
import shutil | |
import time | |
import urllib.parse | |
import requests | |
from bs4 import BeautifulSoup | |
URL = 'http://www.99kubo.com/vod-play-id-5814-sid-3-pid-1.html' | |
PATH = 'c:/tto/' | |
def create_dir(path): | |
if not os.path.exists(path): | |
os.makedirs(path) | |
def fetch_video(url, referer): | |
req = requests.get(url, headers={'Referer': referer}) | |
def fetch_all_video(url): | |
req = requests.get(url) | |
kubovid = re.search("var diy_vid = '(.*?)'", req.text).group(1) | |
kubocid = re.search("var Pid = '(.*?)'", req.text).group(1) | |
data = re.search("ff_urls='(.*?)'", req.text).group(1).replace('\\', '') | |
urls = json.loads(data)['Data'][3]['playurls'] | |
for url in urls: | |
qs = urllib.parse.urlencode({'url': url[1], 'kubovid': kubovid, 'kubocid': kubocid}) | |
url = urllib.parse.urljoin('http://www.99kubo.com/168player/?', qs) | |
referer = 'http://www.99kubo.com' + url[2] | |
fetch_video(url, referer) | |
if __name__ == '__main__': | |
create_dir(PATH) | |
fetch_all_video(URL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment