鱼C论坛

 找回密码
 立即注册
查看: 826|回复: 6

坐等大佬指点!!!!!!!

[复制链接]
发表于 2018-12-28 16:51:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
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()
这个为什么会报错呢
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-12-28 17:10:11 | 显示全部楼层

  1. import re
  2. from urllib import request
  3. class Spider():
  4.     ur1 = "https://www.panda.tv/cate/lol"
  5.     root_pattern = '<div class="video-info">[\s\S]*?</div>'
  6.     def __fetch_content(self):
  7.         r = request.urlopen(Spider.ur1)
  8.         htmls = r.read()
  9.         htmls = str(htmls,encoding = "utf-8")
  10.         return htmls
  11.     def __analysis(self,htmls):
  12.         root_html = re.findall(Spider.root_pattern,htmls)
  13.         print(root_html[0])
  14.         a = 1
  15.     def go(self):
  16.         htmls = self.__fetch_content()
  17.         self.__analysis(htmls)

  18.    
  19. spider = Spider()
  20. spider.go()
复制代码

正则没写对
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-12-28 17:37:50 | 显示全部楼层

谢谢 检查一下正则表达式
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-12-28 17:39:47 | 显示全部楼层
congjieba 发表于 2018-12-28 17:37
谢谢 检查一下正则表达式

不好意思啊 我这段代码是照着一套教学视频敲的 刚才仔细看了下没发现正则表达式那出错了 能麻烦您给具体指出一下吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-12-28 17:44:10 | 显示全部楼层
congjieba 发表于 2018-12-28 17:39
不好意思啊 我这段代码是照着一套教学视频敲的 刚才仔细看了下没发现正则表达式那出错了 能麻烦您给具体 ...

你自己没看仔细,请多看几下,哪里不一样
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-12-28 18:03:21 | 显示全部楼层
塔利班 发表于 2018-12-28 17:44
你自己没看仔细,请多看几下,哪里不一样

麻烦了,我在仔细检查检查
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-12-28 18:11:39 | 显示全部楼层
congjieba 发表于 2018-12-28 18:03
麻烦了,我在仔细检查检查

麻烦您了,问题解决了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-12 16:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表