Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NV: update bills scraper to find votes #4763

Merged

Conversation

braykuka
Copy link
Contributor

Description

I've updated NV bill scraper in order to get votes.

@braykuka
Copy link
Contributor Author

@jessemortenson Please review it and let me know if you have issues.

@jessemortenson
Copy link
Contributor

jessemortenson commented Dec 28, 2023

Hi @braykuka - I ran this and ran into an error about 2 hours into the scrape run:

/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/bin/python -m openstates.cli.update --scrape --fastmode nv bills 
18:43:23 DEBUG openstates.stats: Stat emission is not enabled.
18:43:23 INFO root: Module: nv
nv (scrape)
  bills: {}
18:43:23 INFO openstates: save jurisdiction Nevada as jurisdiction_ocd-jurisdiction-country:us-state:nv-government.json
18:43:23 INFO openstates: save organization Nevada Legislature as organization_1b2601cc-a51a-11ee-ad8b-6ff4fa552a1a.json
18:43:23 INFO openstates: save organization Senate as organization_1b2601cd-a51a-11ee-ad8b-6ff4fa552a1a.json
18:43:23 INFO openstates: save organization Assembly as organization_1b2601ce-a51a-11ee-ad8b-6ff4fa552a1a.json
/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/openstates/cli/update.py:101: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
  "session" in inspect.getargspec(ScraperCls.scrape).args
18:43:23 WARNING openstates: no session provided, using active sessions: {'2023Special35', '2023Special34', '82'}

... [ lots of output omitted here ] ...

20:41:29 INFO nv.bills.VotesTab: fetching https://www.leg.state.nv.us/App/NELIS/REL/82nd2023/Bill/FillSelectedBillTab?selectedTab=Votes&billKey=10448&_=1703731275.3369675
20:41:30 INFO nv.bills.VoteList: fetching https://www.leg.state.nv.us/App/NELIS/REL/82nd2023/Bill/GetBillVotes?billKey=10448&voteTypeId=3
20:41:31 INFO nv.bills.VoteMembers: fetching https://www.leg.state.nv.us/App/NELIS/REL/82nd2023/Bill/GetBillVoteMembers?voteKey=10220&voteResultPanel=All
20:41:32 INFO openstates: save vote_event 82 - 2023-06-05 00:00:00-07:00 - Assembly (As Introduced) as vote_event_9b72ed94-a52a-11ee-ad8b-6ff4fa552a1a.json
Traceback (most recent call last):
  File "/home/jesse/.pyenv/versions/3.9.13/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/jesse/.pyenv/versions/3.9.13/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/openstates/cli/update.py", line 551, in <module>
    sys.exit(main())
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/openstates/cli/update.py", line 541, in main
    report = do_update(args, other, juris)
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/openstates/cli/update.py", line 337, in do_update
    report["scrape"] = do_scrape(juris, args, scrapers, active_sessions)
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/openstates/cli/update.py", line 124, in do_scrape
    partial_report = scraper.do_scrape(**scrape_args, session=session)
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/openstates/scrape/base.py", line 233, in do_scrape
    for obj in self.scrape(**kwargs) or []:
  File "/home/jesse/repo/openstates/braykuka/openstates-scrapers/scrapers/nv/bills.py", line 511, in scrape
    yield from bill_list.do_scrape()
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/spatula/pages.py", line 277, in do_scrape
    yield from self._to_items(scraper)
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/spatula/pages.py", line 228, in _to_items
    yield from item._to_items(scraper)
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/spatula/pages.py", line 228, in _to_items
    yield from item._to_items(scraper)
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/spatula/pages.py", line 235, in _to_items
    yield from result._to_items(scraper)
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/spatula/pages.py", line 224, in _to_items
    for item in result:
  File "/home/jesse/repo/openstates/braykuka/openstates-scrapers/scrapers/nv/bills.py", line 477, in process_page
    votes_members_url = CSS(
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/spatula/selectors.py", line 80, in match_one
    return self.match(element, num_items=1)[0]
  File "/home/jesse/.cache/pypoetry/virtualenvs/openstates-scrapers-YBlM38KZ-py3.9/lib/python3.9/site-packages/spatula/selectors.py", line 57, in match
    raise SelectorError(
spatula.selectors.SelectorError: CSS(.panelAllVoters a) on <div class='col-sm-12 col-md'> @ line 74 got 2 results, expected 1

Process finished with exit code 1

I should have specified a session, looks like it was going through both the regular and a couple special sessions.

@jessemortenson
Copy link
Contributor

Also, checked the data from the part of the scrape that I did get, and found a data problem: it looks like some VoteEvents are showing the counts from the wrong vote. In two example bills I found that the Assembly vote output showed the counts that actually match the Senate vote output. The Senate vote output looked correct.

I'm attaching the JSON output from the scrape, as far as it got. Here are my detailed notes on those examples:

BILL: AB215 (session: 82)

vote_event_ffc17986-a521-11ee-ad8b-6ff4fa552a1a.json

vote_event_0099bba2-a522-11ee-ad8b-6ff4fa552a1a.json

  • looks correct

BILL: AB1 (session: 2023Special34)

vote_event_35f19732-a51a-11ee-ad8b-6ff4fa552a1a.jso

vote_event_35f19733-a51a-11ee-ad8b-6ff4fa552a1a.json

  • looks correct

Could you work on fixes for that data issue and the error above?
nv-231227-jesse.zip

@braykuka
Copy link
Contributor Author

@jessemortenson I will fix them.

@braykuka
Copy link
Contributor Author

braykuka commented Jan 2, 2024

@jessemortenson
could you please check this URL? https://www.leg.state.nv.us/App/NELIS/REL/82nd2023/Bill/10448/Votes
There are 2 senate votes. Should we export both of them or last one only?

@braykuka
Copy link
Contributor Author

braykuka commented Jan 2, 2024

@jessemortenson I've fixed the issue. Please review it again. Thanks.

@jessemortenson
Copy link
Contributor

There are 2 senate votes. Should we export both of them or last one only?

Both of the senate votes. There should be one Vote Event yielded for each vote that occurs on a bill. So for the bill on the URL you cite, there should be 3 Vote Events (two associated with the Senate/upper and one associated with the House/lower).

I'll take another look at the code

@jessemortenson
Copy link
Contributor

I was able to run the full scrape, and the issues remarked upon above are fixed. Thanks!

@jessemortenson jessemortenson merged commit 7a8d23f into openstates:main Jan 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants