-
Notifications
You must be signed in to change notification settings - Fork 0
/
preprocessUrls.py
42 lines (31 loc) · 1.24 KB
/
preprocessUrls.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
35
36
37
38
39
40
41
42
### combine all url.txt files com google scrapy ####
# import os
# with os.scandir("./googleImagesReverseSearch") as it:
# allUrls = []
# for entry in it:
# print(entry.path)
# with open(entry.path) as f:
# content = f.readlines()
# print(len(content))
# allUrls += content
# with open('./allUrls.txt', 'w') as f:
# for item in allUrls:
# f.write("%s" % item)
### remove duplicate lines ####
# with open('./googleReverseSearchUrls.txt', 'r') as f:
# content = f.readlines()
# print(len(content))
# noDuplicationContent = set(content)
# print(len(noDuplicationContent))
# with open('./googleReverseSearchNoDuplication.txt', 'w') as f2:
# for item in noDuplicationContent:
# f2.write("%s" % item)
### compare two files and check how many of them are repeated ####
with open('./googleReverseSearchNoDuplication.txt', 'r') as f:
contentReverse = f.readlines()
print(len(contentReverse))
with open('./googleAndBingUrlsNoDuplication.txt', 'r') as f2:
content = f2.readlines()
print(len(content))
intersection = list(set(content) & set(contentReverse))
print(len(intersection))