|
|
发表于 2018-12-28 17:10:11
|
显示全部楼层
- import re
- from urllib import request
- class Spider():
- ur1 = "https://www.panda.tv/cate/lol"
- root_pattern = '<div class="video-info">[\s\S]*?</div>'
- def __fetch_content(self):
- r = request.urlopen(Spider.ur1)
- htmls = r.read()
- htmls = str(htmls,encoding = "utf-8")
- return htmls
- def __analysis(self,htmls):
- root_html = re.findall(Spider.root_pattern,htmls)
- print(root_html[0])
- a = 1
- def go(self):
- htmls = self.__fetch_content()
- self.__analysis(htmls)
-
- spider = Spider()
- spider.go()
复制代码
正则没写对 |
|