Skip to content

Fix #4: 403 Permission Denied #5

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yunginnanet
Copy link

Summary
This PR adds default HTTP headers (including a User-Agent and other relevant headers) to address the Forbidden error when scraping DoD web directories.

In essence this just reproduces the headers that my browser uses.

Changes

  1. Define a constant defUserAgent to mimic a modern browser.
  2. Initialize an http.Header object with several header fields:
    • User-Agent
    • Accept
    • Accept-Language
    • Upgrade-Insecure-Requests
    • Sec-Fetch-Site
    • Sec-Fetch-User
    • Accept-Encoding
    • Priority
    • Te

Potential Future Improvements
Add a list of UserAgent values and a bit of entropy to the header values in general. This should only be necessary if #4 gets reopened due to changes on DoD's end.

@yunginnanet yunginnanet changed the title Chore: deps Fix #4: 403 Permission Denied Apr 10, 2025
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.

1 participant