Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:05:22+00:00 2026-06-16T17:05:22+00:00

Lets say there’s a file that lives at the github repo: https://github.com/someguy/brilliant/blob/master/somefile.txt I’m trying

  • 0

Lets say there’s a file that lives at the github repo:

https://github.com/someguy/brilliant/blob/master/somefile.txt

I’m trying to use requests to request this file, write the content of it to disk in the current working directory where it can be used later. Right now, I’m using the following code:

import requests
from os import getcwd

url = "https://github.com/someguy/brilliant/blob/master/somefile.txt"
directory = getcwd()
filename = directory + 'somefile.txt'
r = requests.get(url)

f = open(filename,'w')
f.write(r.content)

Undoubtedly ugly, and more importantly, not working. Instead of the expected text, I get:

<!DOCTYPE html>
<!--

Hello future GitHubber! I bet you're here to remove those nasty inline styles,
DRY up these templates and make 'em nice and re-usable, right?

Please, don't. https://github.com/styleguide/templates/2.0

-->
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Page not found &middot; GitHub</title>
    <style type="text/css" media="screen">
      body {
        background: #f1f1f1;
        font-family: "HelveticaNeue", Helvetica, Arial, sans-serif;
        text-rendering: optimizeLegibility;
        margin: 0; }

      .container { margin: 50px auto 40px auto; width: 600px; text-align: center; }

      a { color: #4183c4; text-decoration: none; }
      a:visited { color: #4183c4 }
      a:hover { text-decoration: none; }

      h1 { letter-spacing: -1px; line-height: 60px; font-size: 60px; font-weight: 100; margin: 0px; text-shadow: 0 1px 0 #fff; }
      p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

      ul { list-style: none; margin: 25px 0; padding: 0; }
      li { display: table-cell; font-weight: bold; width: 1%; }
      #error-suggestions { font-size: 14px; }
      #next-steps { margin: 25px 0 50px 0;}
      #next-steps li { display: block; width: 100%; text-align: center; padding: 5px 0; font-weight: normal; color: rgba(0, 0, 0, 0.5); }
      #next-steps a { font-weight: bold; }
      .divider { border-top: 1px solid #d5d5d5; border-bottom: 1px solid #fafafa;}

      #parallax_wrapper {
        position: relative;
        z-index: 0;
      }
      #parallax_field {
        overflow: hidden;
        position: absolute;
        left: 0;
        top: 0;
        height: 370px;
        width: 100%;
      }

etc etc.

Content from Github, but not the content of the file. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:05:23+00:00Added an answer on June 16, 2026 at 5:05 pm

    The content of the file in question is included in the returned data. You are getting the full GitHub view of that file, not just the contents.

    If you want to download just the file, you need to use the Raw link at the top of the page, which will be (for your example):

    https://raw.githubusercontent.com/someguy/brilliant/master/somefile.txt
    

    Note the change in domain name, and the blob/ part of the path is gone.

    To demonstrate this with the requests GitHub repository itself:

    >>> import requests
    >>> r = requests.get('https://github.com/kennethreitz/requests/blob/master/README.rst')
    >>> 'Requests:' in r.text
    True
    >>> r.headers['Content-Type']
    'text/html; charset=utf-8'
    >>> r = requests.get('https://raw.githubusercontent.com/kennethreitz/requests/master/README.rst')
    >>> 'Requests:' in r.text
    True
    >>> r.headers['Content-Type']
    'text/plain; charset=utf-8'
    >>> print r.text
    Requests: HTTP for Humans
    =========================
    
    
    .. image:: https://travis-ci.org/kennethreitz/requests.png?branch=master
    [... etc. ...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php file that show the friends requests, lets say there are
Lets say that there are two tables: Order ID (PK) DateExecuted OrderStep ID (PK)
(This is for a game I am designing) Lets say that there are 2
Lets say that you have a business object whose current state implies that there
Lets say I'm doing a rebase B of a branch onto master and there's
Lets say there is a form with a submit button. I found out that
Lets say there is a website called www.hello.com So what really is www -
So lets say there's a server process that takes way too long. The client
Lets say there is a method that searches for book authors by book id.
The following code outputs the result to a csv file. Lets say there are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.