trying to retrieve comments with activated API key
Drake Gossi
drake.gossi at gmail.com
Fri Mar 8 16:23:12 EST 2019
Ok, I think it worked. Embarrassingly, in my environment, I was clicked on
"help" rather than "variable explorer." This is what is represented:
api_key
string
1
DEMO KEY
docket_id
string
1
ED-2018-OCR-0064
docs_per_page
int
1
1000
total_docs
int
1
32068
Does this mean I can add on the loop? that is, to get all 32000?
and is this in JSON format? it has to be, right? eventually I'd like it to
be in csv, but that's because I assume I have to manipulate it was R
later...
D
On Fri, Mar 8, 2019 at 12:54 PM Chris Angelico <rosuav at gmail.com> wrote:
> On Sat, Mar 9, 2019 at 7:47 AM Drake Gossi <drake.gossi at gmail.com> wrote:
> >
> > Still having issues:
> >
> > 7. import requests
> > 8. import csv
> > 9. import time
> > 10. import sys
> > 11. api_key = 'PUT API KEY HERE'
> > 12. docket_id = 'ED-2018-OCR-0064'
> > 13. total_docs = 32068
> > 14. docs_per_page = 1000
> > 15.
> > 16. r = requests.get("
> https://api.data.gov:443/regulations/v3/documents.json
> > <https://api.data.gov/regulations/v3/documents.json>",
> > 17. params={
> > 18. "api_key": api_key,
> > 19. "dktid": docket_id,
> > 20. "rrp": docs_per_page,
> >
> > })
> >
> > I'm getting an "imported but unused" by 8, 9 & 10.
>
> Doesn't matter - may as well leave them in.
>
> > But then also, on the interactive API
> > <
> https://regulationsgov.github.io/developers/console/#!/documents.json/documents_get_0
> >,
> > it has something called a "po"--i.e., page offset. I was able to figure
> out
> > that "rrp" means results per page, but now I'm unsure how to get all
> 32000
> > comments into a response object. Do I have to add an "ro" on line 21? or
> > something else?
>
> Probably you'll need a loop. For now, don't worry about it, and
> concentrate on getting the first page.
>
> > Also, I ran the code as is starting on line 7 and got this:
> >
> > runfile('/Users/susan/.spyder-py3/temp.py',
> wdir='/Users/susan/.spyder-py3')
> >
> > This was in the terminal, I think. Since nothing popped up in what I
> assume
> > is the environment--I'm running this in spyder--I assume it didn't work.
>
> Ahh, that might be making things confusing.
>
> My recommendation is to avoid Spyder altogether. Just run your script
> directly and let it do its downloading. Keep it simple!
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list