跳到内容
Klang
首页 版块 最新 热门 标签 文档
登录

修复 FinNLP 爬虫bug

已定时 已固定 已锁定 已移动 AI研究
1 帖子 1 发布者 428 浏览
正在加载更多帖子
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • A
    asmcos 管理员
    最后由 编辑

    在使用 FinNLP 提供例子 去获取

    Easymoney

    from finnlp.data_sources.news.eastmoney_streaming import Eastmoney_Streaming
    东方财富 论坛的数据的时候,
    由于 xpath发生了变化。 也就是网友html内部变动了。导致线上代码,不能获取 数据。
    现在 已经 修改, 提交了 issues

    里面包含了正确的代码:
    https://github.com/AI4Finance-Foundation/FinNLP/issues/3

     def _gather_pages(self, stock, page):
         ....
         # gather the comtent of the first page
            page = etree.HTML(response.text)
            trs = page.xpath('//*[@id="mainlist"]/div/ul/li[1]/table/tbody/tr')
            have_one = False
            for item in trs:
                have_one = True
                read_amount = item.xpath("./td[1]//text()")[0]
                comments = item.xpath("./td[2]//text()")[0]
                title = item.xpath("./td[3]/div/a//text()")[0]
                content_link = item.xpath("./td[3]/div/a/@href")[0]
                author = item.xpath("./td[4]//text()")[0]
                time = item.xpath("./td[5]//text()")[0]
                tmp = pd.DataFrame([read_amount, comments, title, content_link, author, time]).T
                columns = [ "read amount", "comments", "title", "content link", "author", "create time" ]
                tmp.columns = columns
                self.dataframe = pd.concat([self.dataframe, tmp])
                #print(title)
            if have_one == False:
                return "break"
       ...
    
    1 条回复 最后回复
    回复 引用 0

    你好!看起来您对这段对话很感兴趣,但您还没有一个账号。

    厌倦了每次访问都刷到同样的帖子?您注册账号后,您下次访问时都将自动回到上次浏览的位置,并可选择接收新回复的通知(通过电子邮件或推送通知)。您还可以收藏帖子、为帖子点赞,以此向其他社区成员表达您的感谢。

    有了你的建议,这篇帖子会更精彩哦 💗

    注册 登录
    • 第一个帖子
      最后一个帖子
    Klang(金浪)AI量化论坛 klang.org.cn 行情 讨论仅供研究,不构成投资建议