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

update script to https #4348

Merged
merged 2 commits into from
Feb 29, 2024
Merged

update script to https #4348

merged 2 commits into from
Feb 29, 2024

Conversation

danielzsh
Copy link
Member

@danielzsh danielzsh commented Feb 27, 2024

Place an "x" in the corresponding checkbox if it is done or does not apply to this pull request.

  • I have tested my code.
  • I have added my solution according to the steps here.
  • I have followed the code conventions mentioned here.
    • I understand that if it is clear that I have not attempted to follow these conventions, my PR will be closed.
    • If changes are requested, I will re-request a review after addressing them.
  • I have linked this PR to any issues that it closes.

@danielzsh
Copy link
Member Author

@thecodingwizard any idea why this doesn't work? python can't fetch https://usaco.org/current/data/dec23_gold_results.html properly, but javascript fetch can?

@thecodingwizard
Copy link
Member

What do you mean by "doesn't work"?

Maybe USACO's ddos protection (cloudflare) thinks we're trying to ddos them. That would be very, very annoying.

@danielzsh
Copy link
Member Author

urllib.request.urlopen('https://usaco.org/current/data/dec23_gold_results.html') causes a 403 Forbidden Error, while fetch('https://usaco.org/current/data/dec23_gold_results.html') works fine. After some googling, others have had issues with urlopen and https but none of the fixes they mentioned worked...

Copy link
Member

@thecodingwizard thecodingwizard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@danielzsh
Copy link
Member Author

wait it still doesn't work though 😭

@thecodingwizard
Copy link
Member

oh.. what if you try a different library, like requests? https://pypi.org/project/requests/ (You are running locally, not on Github Actions, right?)

@mjh316
Copy link
Member

mjh316 commented Feb 28, 2024

import urllib.request
req = urllib.request.Request("https://usaco.org/current/data/dec23_gold_results.html", headers={'User-Agent' : "Magic Browser"}) 
con = urllib.request.urlopen( req )
print(con.read())

Have you tried this fix from here? Seems to work locally for me.

@danielzsh
Copy link
Member Author

danielzsh commented Feb 28, 2024

works for me locally too, lets hope it works on gh actions 🙏 thanks for the help!

Copy link
Member

@thecodingwizard thecodingwizard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@danielzsh
Copy link
Member Author

danielzsh commented Feb 29, 2024

wait what, the workflow on master suddenly started working again 😭 (ah nvm it was for a diff reason)
https://github.com/cpinitiative/usaco-guide/actions/runs/8088739231/job/22103377324

@danielzsh danielzsh merged commit 6dd281e into master Feb 29, 2024
14 checks passed
@danielzsh danielzsh deleted the update-py branch February 29, 2024 00:06
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.

3 participants