-
Notifications
You must be signed in to change notification settings - Fork 0
/
tagInfo.py
36 lines (25 loc) · 831 Bytes
/
tagInfo.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
32
33
34
35
36
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
from urllib.request import urlopen
htmlL = urlopen("http://stackoverflow.com/tags")
bsObjL = BeautifulSoup(htmlL, "html.parser")
nameLi = bsObjL.findAll("a", {"class": "post-tag"})
l = 0
while l < len(nameLi):
html = urlopen("http://stackoverflow.com/tags/" +
nameLi[l].getText() + "/info")
bsObj = BeautifulSoup(html, "html.parser")
tagInfo = bsObj.findAll('div', {'class': 'post-text'})
list = []
m = 0
while m < len(tagInfo):
list.append(tagInfo[m].getText())
m = m + 1
str = list[0]
str.strip(" ")
print(str)
# for tag in tagInfo:
#info = tag.findAll('p')
#print (info)
print("*************************************************************")
l = l + 1