Message Boards Message Boards

0
|
55 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How can I download data from the Securities and Exchange Commission (SEC)?

Posted 6 hours ago

Hello everyone,

I used to be able to download files from the SEC using URLDownload as in

URLDownload[remoteFileName, localFile]

where, when downloading multiple files, I would throttle the loop to respect the SEC's maximum access rate of 10 requests per second. It worked like a charm. But no more. I receive denial messages instead.

The SEC allows programmatic downloading but, since I last downloaded, now requires (I'm quoting the SEC here) the declaration of my user agent in the request headers. I don't know how to do that.

The SEC's help page gives an example of what to include in the request headers.

  • User-Agent: Sample Company Name AdminContact@<sample company domain>.com
  • Accept-Encoding: gzip, deflate
  • Host: www.sec.gov

How would I add this to URLDownload? I am doing research and am not affiliated with a company.

I tried

URLDownload[remoteFileName, localFileName, 
 Authentication -> <|"Username" -> "myEmailUserName@domain.com"|>]

but it did not work. Any tips would be appreciated.

Greg

POSTED BY: Gregory Lypny
2 Replies
Posted 32 minutes ago

You're a lifesaver, Hans. Thanks!

The only change I made to your HTTPRequest suggestion was to replace Automatic with my name and email address and specify the host as www.sec.gov, although I didn't check whether the latter was necessary.

Best regards,

Greg

POSTED BY: Gregory Lypny

Greeting Greg:

Try

URLDownload[
 HTTPRequest[
   remoteFileName, <|"UserAgent" -> Automatic|>],  localFileName]

Hans

POSTED BY: Hans Michel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract