Created
June 10, 2015 06:55
-
-
Save rajasankar/369d2c803b5f18a44ea7 to your computer and use it in GitHub Desktop.
Cleaning up downloaded files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outfilename=<html file to write> | |
number_of_pages= #number of files downloaded from site | |
for i in range(1,number_of_pages): | |
data=urllib2.urlopen(outfilename) | |
soup = BeautifulSoup(data) | |
data=soup.prettify() | |
soup = BeautifulSoup(data) | |
ti=soup.findAll(attrs={'class':'link'}) | |
for t in ti: | |
t.extract() | |
ti=soup.findAll(attrs={'class':'thead'}) | |
for t in ti: | |
t.extract() | |
hr=soup.findAll('hr') | |
for h in hr: | |
h.extract() | |
hr=soup.findAll('form') | |
for h in hr: | |
h.extract() | |
hr=soup.findAll('head') | |
for h in hr: | |
h.extract() | |
hr=soup.findAll('input') | |
for h in hr: | |
h.extract() | |
print soup.prettify() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment