import sys,os |
import sys,os |
sys.path.insert(0, os.path.join(os.path.dirname(__file__) or '.', '../')) |
sys.path.insert(0, os.path.join(os.path.dirname(__file__) or '.', '../')) |
import genericScrapers |
import genericScrapers |
#RSS feed not detailed |
import dateutil |
|
from dateutil.parser import * |
|
from datetime import * |
|
import scrape |
|
from bs4 import BeautifulSoup |
|
class ScraperImplementation(genericScrapers.GenericOAICDisclogScraper): |
|
|
#http://www.doughellmann.com/PyMOTW/abc/ |
def __init__(self): |
class ScraperImplementation(genericScrapers.GenericRSSDisclogScraper): |
super(ScraperImplementation, self).__init__() |
def getAgencyID(self): |
def getTable(self, soup): |
return "be9996f0ac58f71f23d074e82d44ead3" |
return soup.find(id='zone-content') |
|
|
def getURL(self): |
def getDescription(self,content, entry,doc): |
return "http://foi.deewr.gov.au/disclosure-log/rss" |
link = None |
|
links = [] |
|
description = "" |
|
for atag in entry.find_all('a'): |
|
if atag.has_attr('href'): |
|
link = scrape.fullurl(self.getURL(), atag['href']) |
|
(url, mime_type, htcontent) = scrape.fetchURL(scrape.docsdb, link, "foidocuments", self.getAgencyID(), False) |
|
if htcontent != None: |
|
if mime_type == "text/html" or mime_type == "application/xhtml+xml" or mime_type =="application/xml": |
|
soup = BeautifulSoup(htcontent) |
|
row = soup.find(id="foidetails") |
|
if row == None: |
|
row = soup.find(id="content").table |
|
if row == None: |
|
row = soup.find(id="content") |
|
description = ''.join(row.stripped_strings) |
|
for atag in row.find_all("a"): |
|
if atag.has_attr('href'): |
|
links.append(scrape.fullurl(link, atag['href'])) |
|
|
def getColumns(self,columns): |
if links != []: |
(id, date, title, description, notes) = columns |
doc.update({'links': links}) |
return (id, date, description, title, notes) |
if description != "": |
|
doc.update({ 'description': description}) |
|
|
|
def getColumnCount(self): |
|
return 3 |
|
|
|
def getColumns(self, columns): |
|
(id, title, date) = columns |
|
return (id, date, title, title, None) |
|
|
|
|
if __name__ == '__main__': |
if __name__ == '__main__': |
print 'Subclass:', issubclass(ScraperImplementation, genericScrapers.GenericRSSDisclogScraper) |
print 'Subclass:', issubclass(ScraperImplementation, genericScrapers.GenericOAICDisclogScraper) |
print 'Instance:', isinstance(ScraperImplementation(), genericScrapers.GenericRSSDisclogScraper) |
print 'Instance:', isinstance(ScraperImplementation(), genericScrapers.GenericOAICDisclogScraper) |
ScraperImplementation().doScrape() |
ScraperImplementation().doScrape() |
|
|
www.finance.gov.au/foi/disclosure-log/foi-rss.xml |
|
|
|