This repository was archived by the owner on Jun 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
Stack_Overflow_Parser-master Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Stack_Overflow_Parser
2
+
3
+ Parses SO for your error messages, hope this helps.
4
+
5
+ Let's connect for some interesting project.
6
+
Original file line number Diff line number Diff line change
1
+ import shlex
2
+ import requests
3
+ from subprocess import Popen , PIPE
4
+
5
+ def execute_and_return (cmd ):
6
+ """
7
+ Execute the external command and get its exitcode, stdout and stderr.
8
+ """
9
+ args = shlex .split (cmd )
10
+ proc = Popen (args , stdout = PIPE , stderr = PIPE )
11
+ out , err = proc .communicate ()
12
+ return out , err
13
+
14
+ def make_request (error ):
15
+ print ("Searching for " + error )
16
+ resp = requests .get ("https://api.stackexchange.com/" + "2.2/search?order=desc&tagged=python&sort=activity&intitle={}&site=stackoverflow" .format (error ))
17
+ return resp .json ()
18
+
19
+ def get_urls (json_dict ):
20
+ url_list = []
21
+ count = 0
22
+ for i in json_dict ['items' ]:
23
+ if i ["is_answered" ]:
24
+ url_list .append (i ["link" ])
25
+ count += 1
26
+ if count == len (i ) or count == 3 :
27
+ break
28
+ import webbrowser
29
+ for i in url_list :
30
+ webbrowser .open (i )
31
+
32
+
33
+
34
+
35
+ if __name__ == "__main__" :
36
+ out , err = execute_and_return ("python test.py" )
37
+ error_message = err .decode ("utf-8" ).strip ().split ("\r \n " )[- 1 ]
38
+ print (error_message )
39
+ if error_message :
40
+ filter_out = error_message .split (":" )
41
+ print (filter_out )
42
+ print (filter_out [0 ])
43
+ json1 = make_request (filter_out [0 ])
44
+ json2 = make_request (filter_out [1 ])
45
+ json = make_request (error_message )
46
+ get_urls (json1 )
47
+ get_urls (json2 )
48
+ get_urls (json )
49
+ else :
50
+ print ("No errors" )
51
+
Original file line number Diff line number Diff line change
1
+ a = 5 + "b"
You can’t perform that action at this time.
0 commit comments