市政当局的议程刮板框架
engage-scraper的Python项目详细描述
接合刮刀
安装
pip i engage-scraper
关于
Engage Scraper是一个独立的库,可以包含在任何服务中。scraper的目的是以一种可用的格式对市政会议议程进行分类,例如engage-client和engage-backend。
要为您的自治市扩展此库,请重写scraper_core/
目录中基类的方法,并将其放在scraper_logics/
中,并在其前面加上您的自治市名称。有关示例,请参见scraper_logics/
目录中的santa monica,ca示例。Santa Monica示例使用htmlutils.py
,因为它需要对其源代码进行HTML抓取。可以使用新的实用程序(例如,pdf抓取、rss抓取、json解析等)创建prs。Santa Monica示例还使用SqlAlchemy作为其模型,这是在dbutils.py
中使用的首选方法,但是您可以使用任何东西。比起香草的psycopg2之类的,orms是首选的。
要使用postgresdbutils.py
请确保设置这两个环境变量:
POSTGRES_URI
形式的uri字符串username:password@hostname
POSTGRES_DB
用于编目市政议程的数据库。
使用Santa Monica Scraper库的示例
from engage_scraper.scraper_logics import santamonica_scraper_logic scraper = santamonica_scraper_logic.SantaMonicaScraper(committee="Santa Monica City Council") scraper.get_available_agendas() scraper.scrape()
对于Santamonicascacraper实例化
参数为:
tz_string="America/Los_Angeles"
默认字符串years=["2019"]
默认的年份字符串数组committee="Santa Monica City Council"
理事会名称的默认字符串
刮板外露api方法
.get_available_agendas()
要获得可用的议程,不需要参数.scrape()
处理议程并存储内容
请随意多曝光
- 如果要公开内部函数,请为其编写包装器
- 编写额外的功能来处理更复杂的市政特定任务