KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 · 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; }
Tags (comma-separated)
Save Edits
Cancel