-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfindBoardId.py
executable file
·35 lines (27 loc) · 1.09 KB
/
findBoardId.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
import os
import re
import csv
import logging
import gzip
import re
#loggin setup
logging.basicConfig(filename="findBoardID.log", filemode="a", level=logging.INFO, format="[ %(asctime)s ] %(levelname)s : %(message)s")
saida = open("findBoardId.txt","w")
#build header
saida.write("pinId;boardId\n")
for arq in os.listdir("./profiles"):
try:
logging.info("["+arq+"]: iniciando" )
for board in os.listdir("./profiles/"+arq+"/boards/"):
try:
photos = open('./profiles/'+arq+'/boards/'+board+'/timeline',"r")
csvPhotos = csv.reader(photos,delimiter=";")
for photo in csvPhotos:
pinPage = gzip.open('./profiles/'+arq+'/boards/'+board+'/'+photo[0],"r").read()
boardId = re.findall('<meta property="pinterestapp:pinboard" name="pinterestapp:pinboard" content="(.*)" data-app="">',pinPage)[0].strip()
saida.write(photo[0]+";"+str(boardId.replace("http://www.pinterest.com/",""))+"\n")
except :
logging.error("["+ arq+"]: nao tem o seguinte board attribute: "+board)
except :
logging.error("["+ arq+"]: nao existe mais")