-
Notifications
You must be signed in to change notification settings - Fork 2
/
marshal.py
32 lines (28 loc) · 987 Bytes
/
marshal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json
import re
import webbrowser
from urllib.request import urlopen
from bs4 import BeautifulSoup
result = []
def find_bad_qn(a):
url="https://stackoverflow.com/questions?page="+str(a)+"&sort=newest"
html = urlopen(url)
bsObj = BeautifulSoup(html,"html5lib")
que= bsObj.find_all("div", class_="question-summary")
for div in que:
vote=int(div.find('span').text.split(' ')[0])
link=div.a.get('href')
name=div.a.text
if(vote<-2 and not bool(re.search('(\[on hold\]|\[duplicate\]|\[closed\])$', name))):
result.append({'link': link, 'vote': vote,'name':name})
for i in range(50,70):
find_bad_qn(i)
for qn in result:
qn['link']="https://stackoverflow.com"+qn['link']
result = json.dumps({'result': sorted(result, key=lambda x: x['vote'], reverse=False)})
result=json.loads(result)
print("Please Wait.. it will take some time")
for qn in result['result']:
print(qn['link']," Votes :", qn['vote'])
url=qn['link']
webbrowser.open(url, new=0, autoraise=True)