File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import requests
2
+ import argparse
3
+
4
+ def main (args ):
5
+ URL = f"https://api.github.com/users/{ args .u } "
6
+ res = requests .get (URL ).json ()
7
+ output = ""
8
+ output += "Username: " + res ['login' ]
9
+ if (res ['name' ]):
10
+ output += "\n Name: " + res ['name' ]
11
+ if (res ['bio' ]):
12
+ output += "\n Bio: " + res ['bio' ]
13
+ if (res ['email' ]):
14
+ output += "\n Email: " + res ['email' ]
15
+ output += "\n Followers: " + str (res ['followers' ])
16
+ output += "\n Following: " + str (res ['following' ])
17
+
18
+ print (output )
19
+ with open (f"{ res ['login' ]} .txt" ,"w" ) as f :
20
+ f .write (output )
21
+ print (f"Output written in { res ['login' ]} .txt" )
22
+
23
+ parser = argparse .ArgumentParser (
24
+ "This Script lists info about the github user"
25
+ )
26
+ parser .add_argument ("-u" , help = "The name of the user" , type = str , required = True )
27
+
28
+ args = parser .parse_args ()
29
+ main (args )
You can’t perform that action at this time.
0 commit comments