View difference between Paste ID: QhfWEwtz and Gy9n9VCh
SHOW: | | - or go back to the newest paste.
1
import urllib2
2
import re
3
url = "http://services.runescape.com/m=news/behind-the-scenes-video-30-player-owned-ports-"
4
print "Printing stuffs..."
5
a = urllib2.urlopen(url).read()
6-
b = a[a.index('<div class=\"Content\">'):] 
6+
a = a[a.index('<div class=\"Content\">')+21:]
7-
c = b[:b.index('</div>')]
7+
a = a[:a.index('</div>')]
8-
cc = c.decode("windows-1252")
8+
a = a.decode("windows-1252")
9-
html = cc.replace("<p>", "\n\n")
9+
a = a.replace('\n','')
10-
html = re.sub(r"</?b>", "\'\'\'", html, flags = "g")
10+
html = a.replace("</p>", "\n\n").replace('<p>','')
11-
html = re.sub(r"</?i>", "\'\'", html, flags = "g")
11+
html = re.sub(r"</?b>", "'''", html)
12-
html = re.sub(r"</?li>", "\n", html, flags = "g")
12+
html = re.sub(r"</?i>", "''", html)
13-
html = re.sub(r"</?ul>", "\n", html, flags = "g")
13+
html = html.replace('<li>','*').replace('</li>','\n')
14-
html = re.sub(r'<a.*?href="(.*?)".*?>(.*?)<\/a>', '[$1, $2]', html, flags = "g")
14+
html = re.sub(r"</?ul>", "\n", html)
15-
html = re.sub(r'<a.*?href="?([^ "]*)"?.*?>(.*?)<\/a>', "[$1, $2]", html, flags = "g")
15+
html = re.sub(r'<a.*?href="?([^ "]*)"?.*?>(.*?)<\/a>', r"[\1 \2]", html)
16-
html = re.sub(r'<hr.*?>', "\n----\n", html, flags = "g")
16+
html = re.sub(r'<hr.*?>', "\n----\n", html)
17-
html = re.sub(r'<iframe.*?embed\/(.*?)".*?<\/iframe>', '<youtube>$1</youtube>', html, flags = "g")
17+
html = re.sub(r'<iframe.*?embed\/(.*?)".*?<\/iframe>', r'<youtube>\1</youtube>\n\n', html)
18
html = re.sub(r'\n{4,}','\n\n',html)
19
print html