-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathFileComparison.py
More file actions
55 lines (35 loc) · 1.15 KB
/
FileComparison.py
File metadata and controls
55 lines (35 loc) · 1.15 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
import requests
import urllib.request
from bs4 import BeautifulSoup
import zipfile, io
import os
url= 'http://staging.imgtranslate.com:9999/'
extension = ".zip"
r = requests.get(url)
html_content=r.text
soup= BeautifulSoup(html_content, "html.parser")
for anchor in soup.findAll('a', href=True):
links = url + anchor['href']
if links.endswith(extension):
r2 = requests.get(links)
z = zipfile.ZipFile(io.BytesIO(r2.content))
z.extractall()
TextFiles = []
cwd = os.getcwd()
for i in os.listdir(cwd+'/a'):
if i.endswith('.txt'):
TextFiles.append(cwd+'/a'+'/'+i)
for j in os.listdir(cwd+'/b'):
if j.endswith('.txt'):
TextFiles.append(cwd+'/b'+'/'+j)
for k in os.listdir(cwd+'/c'):
if k.endswith('.txt'):
TextFiles.append(cwd+'/c'+'/'+k)
for a in TextFiles:
for b in TextFiles:
with open(a) as file1:
with open(b) as file2:
commonLine = set(file1).intersection(file2)
commonLine.discard('\n')
if len(commonLine)!=0 and a!=b:
print(str(os.path.basename(a))+ ' ' +str(os.path.basename(b)))