本文整理汇总了Python中legistar.scraper.LegistarScraper类的典型用法代码示例。如果您正苦于以下问题:Python LegistarScraper类的具体用法?Python LegistarScraper怎么用?Python LegistarScraper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LegistarScraper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_sponsors
def parse_sponsors():
with open("tests/local/LegislationDetail.aspx?ID=1255978&GUID=8051C1E6-DED6-433B-AC9A-0FE436051C9F") as f:
soup = BeautifulSoup(f)
config = Config(hostname="chicago.legistar.com", fulltext=True).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
legislation_details = scraper.parseLegislationDetail(soup)
assert_equal(legislation_details[0]["Sponsors"][1], u"Moreno, Proco Joe")
示例2: link_address_is_none
def link_address_is_none():
config = Config(hostname="phila.legistar.com", sponsor_links=False).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
from BeautifulSoup import BeautifulSoup
link = BeautifulSoup("<html><a></a></html>").find("a")
address = scraper._get_link_address(link)
assert_is_none(address)
示例3: supports_simple_initial_search_form
def supports_simple_initial_search_form():
config = Config(hostname="phila.legistar.com", fulltext=True).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
summaries = scraper.searchLegislation("")
try:
summaries.next()
except StopIteration:
fail("no legislation found")
示例4: recognize_dates
def recognize_dates():
config = {"hostname": "phila.legistar.com", "date_format": "%m/%d/%Y", "fulltext": True}
scraper = LegistarScraper(config)
summaries = scraper.searchLegislation("")
summary = summaries.next()
import datetime
assert_is_instance(summary["File Created"], datetime.datetime)
示例5: supports_fetching_council_members
def supports_fetching_council_members():
config = Config(hostname="phila.legistar.com", fulltext=True).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
members = scraper.councilMembers()
try:
members.next()
except StopIteration:
fail("no council members found")
示例6: supports_simple_initial_search_form
def supports_simple_initial_search_form():
config = {"hostname": "phila.legistar.com", "fulltext": True}
scraper = LegistarScraper(config)
summaries = scraper.searchLegislation("")
try:
summaries.next()
except StopIteration:
fail("no legislation found")
示例7: parse_sponsors
def parse_sponsors():
config = {"hostname": "chicago.legistar.com", "fulltext": True}
scraper = LegistarScraper(config)
legislation_summary = {
"URL": "http://chicago.legistar.com/LegislationDetail.aspx?ID=1255978&GUID=8051C1E6-DED6-433B-AC9A-0FE436051C9F"
}
legislation_details = scraper.expandLegislationSummary(legislation_summary)
assert_equal(legislation_details[0]["Sponsors"][1], u"Moreno, Proco Joe")
示例8: recognize_dates
def recognize_dates():
config = Config(hostname="phila.legistar.com", sponsor_links=False, date_format="%m/%d/%Y").defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
summaries = scraper.searchLegislation("")
summary = summaries.next()
import datetime
assert_is_instance(summary["File Created"], datetime.datetime)
示例9: supports_fetching_calendar
def supports_fetching_calendar():
config = Config(hostname="phila.legistar.com", fulltext=False).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
events = scraper.councilCalendar("all")
try:
events.next()
except StopIteration:
fail("no events found")
示例10: philly_sponsors
def philly_sponsors():
config = Config(hostname="phila.legistar.com", sponsor_links=False).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
legislation_summary = {
"URL": "http://phila.legistar.com/LegislationDetail.aspx?ID=1233260&GUID=DC103FB6-FF9D-4250-B0CE-111B80E8B80C"
}
legislation_details = scraper.expandLegislationSummary(legislation_summary)
assert_equal(legislation_details[0]["Sponsors"][0], u"Councilmember DiCicco")
示例11: supports_advanced_initial_search_form
def supports_advanced_initial_search_form():
config = Config(hostname="chicago.legistar.com", fulltext=True).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
summaries = scraper.searchLegislation("")
try:
summaries.next()
except StopIteration:
# fail('no legislation found')
assert False
示例12: paging_through_legislation
def paging_through_legislation():
config = Config(hostname="chicago.legistar.com", fulltext=True).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
summaries = list(scraper.searchLegislation("pub"))
# Making summaries a list forces the scraper to iterate completely through
# the generator
for s in summaries:
print s["Record #"]
assert_greater(len(summaries), 100)
示例13: paging_through_results
def paging_through_results():
config = {"hostname": "chicago.legistar.com", "fulltext": True}
scraper = LegistarScraper(config)
summaries = list(scraper.searchLegislation("pub"))
# Making summaries a list forces the scraper to iterate completely through
# the generator
for s in summaries:
print s["Record #"]
assert_greater(len(summaries), 100)
示例14: parse_detail_keys
def parse_detail_keys():
config = Config(hostname="phila.legistar.com", fulltext=True).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)
summary = {
"URL": "http://phila.legistar.com/LegislationDetail.aspx?ID=1265815&GUID=97CBBF7C-A123-4808-9D50-A1E340BE5BC1"
}
detail = scraper.expandLegislationSummary(summary)
assert_in(u"Version", detail[0].keys())
assert_not_in(u"CITY COUNCIL", detail[0].keys())
示例15: link_address_is_onclick
def link_address_is_onclick():
config = {"hostname": "phila.legistar.com", "fulltext": True}
scraper = LegistarScraper(config)
from BeautifulSoup import BeautifulSoup
link = BeautifulSoup("<html><a onclick=\"radopen('http://www.google.com');\"></a></html>").find("a")
address = scraper._get_link_address(link)
assert_equal(address, "http://www.google.com")