from urllib import request
import re
class Spider():
url = "http://www.yy.com/game/"
root_pattern = '
a = 1
def __analysis(self,htmls):
root_html = re.findall(Spider.root_pattern,htmls)
anchors = []
for html in root_html:
name = re.findall(Spider.name_pattern,html)
number = re.findall(Spider.number_pattern,html)
anchor = {"主播名称":name,"观看人数":number}
anchors.append(anchor)
print(anchors)
def go(self):
htmls = self.__fetch_content()
self.__analysis(htmls)
spider = Spider()
spider.go()