Created
August 22, 2018 17:25
-
-
Save victorlin/bceef5d3abf94293063ac3672ce33bbc to your computer and use it in GitHub Desktop.
tracking stats of a re-uploaded video
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
import urllib | |
import datetime | |
import time | |
import string | |
url = "https://www.facebook.com/theKLIQUE/videos/1079723095393383/" | |
def printStuff(): | |
fileObj = urllib.urlopen(url) | |
mylist = [] | |
today = datetime.datetime.now() | |
mylist.append(today) | |
returnstring = str(mylist[0]) | |
returnstring += "," | |
for line in fileObj: | |
if ('<span id="fbPhotoPageExpiration"></span><div></div><span class="fcg">' in line): | |
startIndex = line.find('<span id="fbPhotoPageExpiration"></span><div></div><span class="fcg">') + 69 | |
endIndex = line.find('Views') | |
returnstring += line[startIndex:endIndex] | |
returnstring += "," | |
if ('"sharecount":' in line): | |
startIndex = line.find('sharecount') + 12 | |
endIndex = line.find('sharecountreduced') - 2 | |
returnstring += line[startIndex:endIndex] | |
return returnstring | |
finish_time = datetime.datetime.now() + datetime.timedelta(hours=6) | |
while 1: | |
print 'Running tracker...' | |
while 1: | |
if datetime.datetime.now() < finish_time: | |
mylist = [] | |
today = datetime.datetime.now() | |
mylist.append(today) | |
print mylist[0] | |
writeString = printStuff() + "\n" | |
with open('video_info.csv', 'a') as file: | |
file.write(writeString) | |
time.sleep(300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment