-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tree_serial.py
59 lines (52 loc) · 1.65 KB
/
Tree_serial.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
################ URL opener ############
import bs4
import urllib.request as ur
import requests
class pro:
def __init__(self):
self.url = ''
self.header = { 'USER_AGENT' : 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0'}
def latest(self):
file_name='resource_1.txt'
new_f = open( file_name,'w')
with open('urlnew.txt') as f:
for line in f:
## print(line)
line = line.strip('\n')
len1 = line.find('serial')
if(len1 !=-1):
len1 = line[0:len1+6]
if( "..." not in line) :
new_f.write(len1+'/')
new_f.write('\n')
elif (line.find('Serial')!=-1):
len1 = line[0:line.find('Serial')+6]
if( "..." not in line) :
new_f.write(len1+'/')
new_f.write('\n')
elif (line.find('Show')!=-1):
len1 = line[0:line.find('Show')+4]
if( "..." not in line) :
new_f.write(len1+'/')
new_f.write('\n')
elif (line.find('show')!=-1):
len1 = line[0:line.find('show')+4]
if( "..." not in line) :
new_f.write(len1+'/')
new_f.write('\n')
elif (line.find('series')!=-1):
len1 = line[0:line.find('series')+6]
if( "..." not in line) :
new_f.write(len1+'/')
new_f.write('\n')
elif (line.find('Series')!=-1):
len1 = line[0:line.find('Series')+6]
if( "..." not in line) :
new_f.write(len1+'/')
new_f.write('\n')
else:
print(line)
new_f.close()
print("done")
r=pro()
r.latest()