-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to archive the monthly text/gzip files
- Loading branch information
Showing
4 changed files
with
84 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.pyc | ||
MailmanArchiveScraper.cfg |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
from BeautifulSoup import BeautifulSoup | ||
from MailmanArchiveScraper import MailmanArchiveScraper | ||
|
||
""" | ||
Download the gzip text file with the month's messages. | ||
""" | ||
class MailmanGzTextScraper(MailmanArchiveScraper): | ||
|
||
def __init__(self): | ||
super(MailmanGzTextScraper, self).__init__() | ||
self.local_dir = self.publish_dir + 'text' | ||
if not os.path.exists(self.local_dir): | ||
os.mkdir(self.local_dir) | ||
|
||
""" | ||
fetch the the whole month's message as gzipped text | ||
""" | ||
def scrapeList(self): | ||
source = self.fetchPage(self.list_url) | ||
filtered_source = self.filterPage(source) | ||
soup = BeautifulSoup(source) | ||
|
||
|
||
for row in soup.first('table')('tr')[1:]: | ||
rel_url = row('td')[2]('a')[0].get('href') | ||
source = self.fetchPage(self.list_url + '/' + rel_url) | ||
|
||
local_month = open(self.local_dir + '/' + rel_url, 'w') | ||
local_month.write(source) | ||
local_month.close() | ||
|
||
|
||
|
||
def main(): | ||
scraper = MailmanGzTextScraper() | ||
scraper.scrape() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
|
This file contains 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