Skip to content

Instantly share code, notes, and snippets.

@fedarko
Created October 2, 2019 22:10
Show Gist options
  • Save fedarko/4fc177cff9084b9e325dcbe954547edc to your computer and use it in GitHub Desktop.
Save fedarko/4fc177cff9084b9e325dcbe954547edc to your computer and use it in GitHub Desktop.
Convert a github file URL to a raw.githubusercontent.com URL (that can be directly accessed for things like view.qiime2.org or wget)
# your link goes here
link = "https://github.com/knightlab-analyses/qurro-mackerel-analysis/blob/master/AnalysisOutput/qurro-plot.qzv"
# note: this will break if a repo/organization or subfolder is named "blob" -- would be ideal to use a fancy regex
# to be more precise here
print(link.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/"))
# example output link:
# https://raw.githubusercontent.com/knightlab-analyses/qurro-mackerel-analysis/master/AnalysisOutput/qurro-plot.qzv
@wamod
Copy link

wamod commented May 3, 2022

تحديث جديد``
حمله الان

تحديثتحديث

@Lastuu1234
Copy link

your link goes here

link = "https://github.com/Lastuu1234/dahoodlockraw"

note: this will break if a repo/organization or subfolder is named "blob" -- would be ideal to use a fancy regex

to be more precise here

print(link.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/"))

example output link:

https://raw.githubusercontent.com/knightlab-analyses/qurro-mackerel-analysis/master/AnalysisOutput/qurro-plot.qzv

@sanjay-ar
Copy link

this is working...just erase the blob which is on the link that we get from repo and cut the word blob from the link then our link is ready to view our page at website

@agzam
Copy link

agzam commented Nov 22, 2022

Doesn't work for file urls in private repos. Those require a token. If someone knows how to generate the token, please share.

@sdotgo
Copy link

sdotgo commented Apr 6, 2023

how to use

@DjN3lson
Copy link

anyone know how it would look like with this one?
https://github.com/DjN3lson/cryptoo/blob/main/CodeCoinLogo.png

@kumarniti4
Copy link

Doesn't work for file urls in private repos. Those require a token. If someone knows how to generate the token, please share.

You need to generate your personal access token and send that in the header with Name: Authorization and Value: Token <personal_access_token>

@Lisipo0i
Copy link

Kjddk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment