Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions llluiop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Windows image file caches


# Folder config file
.idea

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files

# =========================
# Operating System Files
# =========================

# OSX
# =========================



# Icon must end with two \r


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share

43 changes: 43 additions & 0 deletions llluiop/0008/MianText.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin.env python


from HTMLParser import HTMLParser
from re import sub
import urllib2
import sys


class HtmlParserMainText(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.text = []

def handle_starttag(self, tag, attrs):
if tag == "p":
self.text.append("\n")

def handle_data(self, data):
if len(data.strip()) > 0:
self.text.append(data.strip())



def GetMainText():
url = "http://www.bbc.com/"
html = urllib2.urlopen(url).read()
html_code = sub('<script[^>]*?>[^>]*?</script>','',html) #delete all scripts



parser = HtmlParserMainText()
parser.feed(html_code)
parser.close()

return ''.join(parser.text).strip()


if __name__ == "__main__":

reload(sys)
sys.setdefaultencoding('utf-8')
print GetMainText()