Created
August 4, 2018 23:51
-
-
Save coeric/7b27c7e24afc9ebea847375e7db38b82 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
#-*- coding:utf-8 -*- | |
#!/usr/bin/env python | |
import requests | |
from bs4 import BeautifulSoup | |
import re | |
import shutil | |
import os | |
out='/home/coericnb' | |
def get_video(url): | |
res=requests.get(url) | |
soup=BeautifulSoup(res.content,'html.parser') | |
temp=soup.findAll('script') | |
for i in temp: | |
if re.search("html5player.setVideoUrlHigh",i.text): | |
m= re.search("html5player.setVideoUrlHigh\('(.*?)'\);",i.text) | |
n= re.search("html5player.setVideoTitle\('(.*?)'\);",i.text) | |
url_mov=m.group(1) | |
filename=n.group(1)+".mp4" | |
# print filename | |
res_mov=requests.get(url_mov,stream=True) | |
path=os.path.join(out,filename) | |
if os.path.exists(path) and os.path.getsize(path)>0:pass | |
else: | |
f=open(path,'wb') | |
shutil.copyfileobj(res_mov.raw,f) | |
f.close() | |
def get_list(): | |
url="http://www.xvideos.com/" | |
res=requests.get(url) | |
soup=BeautifulSoup(res.content,'html.parser') | |
temp=soup.find('div',attrs={'class':'mozaique'}).findAll('div',attrs={'class':'thumb-block '}) | |
for i in temp: | |
url_mov="https://www.xvideos.com"+i.findAll('a')[0]['href'] | |
print url_mov | |
get_video(url_mov) | |
get_list() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment