-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUrlTest.py
32 lines (32 loc) · 1 KB
/
UrlTest.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
import sys,urllib.request
url="http://www.putclub.com/html/radio/VOA/presidentspeech/index.html"
wp = urllib.request.urlopen(url)
print('start download...')
content = wp.read()
#center_box = content.count("center_box")
#print(content.count("center_box"))
print(type(content))
content = str(content)
center_box = content.count("center_box")
print(center_box)
index = content.find("center_box")
content=content[content.find("center_box")+1:]
content=content[content.find("href=")+7:content.find("target")-2]
filename = content
url ="http://www.putclub.com/"+content
print(content)
print(url)
wp = urllib.request.urlopen(url)
print('start download...')
content = wp.read()
#print content
#print content.count(""):]
print(type(content))
content = str(content)
content = content[:content.find("<div class=\"dede_pages\"")-1]
filename = filename[filename.find("presidentspeech")+len("presidentspeech/"):]
filename = filename.replace('/',"-",filename.count("/"))
fp = open(filename,"w+")
fp.write(content)
fp.close()
print(content)