RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-296823

zrx's questions

Martin Hope
zrx
Asked: 2023-07-16 21:53:25 +0000 UTC

网站解析和文本翻译

  • 6

面临这样的任务:
需要解析网站并将生成的文本翻译成俄语,同时保持文本的结构

以下是需要解析的HTML :

<div>
   <style data-emotion="css gy2lsd">
      .css-gy2lsd{
         margin:0;
         font-family:'DM Sans',sans-serif;
         font-weight:400;
         font-size:1rem;
         line-height:1.5;
         margin:15px 0;
      }
   </style>
   <p class="MuiTypography-root MuiTypography-body1 css-gy2lsd">
      <strong>Nexus </strong>is the pioneering AI-powered navigator <em>designed to assist users</em> in effectively navigating their entire network.
   </p>
   <p class="MuiTypography-root MuiTypography-body1 css-gy2lsd">
      <strong>Key Features:</strong>
   </p>
   <style data-emotion="css 196imzh">
      .css-196imzh{
         list-style:none;
         margin:0;
         padding:0;
         position:relative;
         padding-top:8px;
         padding-bottom:8px;
         list-style-type:disc;
         padding-left:16px;
      }
      
      .css-196imzh .MuiListItem-root{
         display:-webkit-box;
         display:-webkit-list-item;
         display:-ms-list-itembox;
         display:list-item;
         }
      </style>
   <ul class="MuiList-root MuiList-padding css-196imzh">=
      <li class="MuiListItem-root MuiListItem-gutters MuiListItem-padding css-1uxc9es">
         <style data-emotion="css 1tsvksn">.css-1tsvksn{-webkit-flex:1 1 auto;-ms-flex:1 1 auto;flex:1 1 auto;min-width:0;margin-top:4px;margin-bottom:4px;}</style>
         <div class="MuiListItemText-root css-1tsvksn">
            <style data-emotion="css iwjgli">.css-iwjgli{margin:0;font-family:'DM Sans',sans-serif;font-weight:400;font-size:1rem;line-height:1.5;display:block;}</style>
            <span class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-iwjgli"><strong>AI-powered network navigation:</strong> Leverage cutting-edge AI technology to effectively navigate your entire network.</span>
         </div>
      </li>
      <li class="MuiListItem-root MuiListItem-gutters MuiListItem-padding css-1uxc9es">
         <div class="MuiListItemText-root css-1tsvksn"><span class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-iwjgli"><strong>Comprehensive relationship context:</strong> Access contextual knowledge about your connections to facilitate smoother interactions.</span></div>
      </li>
      <li class="MuiListItem-root MuiListItem-gutters MuiListItem-padding css-1uxc9es">
         <div class="MuiListItemText-root css-1tsvksn"><span class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-iwjgli"><strong>Assistance with various networking tasks: </strong>Seek help from Nexus for reasons to reconnect, outreach email ideas, and personalized gift recommendations.</span></div>
      </li>
   </ul>
   <p class="MuiTypography-root MuiTypography-body1 css-gy2lsd"><strong>Use Cases:</strong></p>
   <p class="MuiTypography-root MuiTypography-body1 css-gy2lsd"><strong>• Strengthening client relationships:</strong> Deepen your connections with key clients using Nexus's insights and guidance.</p>
   <p class="MuiTypography-root MuiTypography-body1 css-gy2lsd"><strong>• Managing stakeholder relationships:</strong> Effectively handle multiple stakeholders with Nexus's support and recommendations.</p>
   <p class="MuiTypography-root MuiTypography-body1 css-gy2lsd"><strong>• Enhancing networking efficiency: </strong>Save time and improve networking outcomes by leveraging Nexus's comprehensive understanding of your network.</p>
   <p class="MuiTypography-root MuiTypography-body1 css-gy2lsd">Experience the future of networking today with Nexus, the first AI navigator for your entire network.</p>
</div>

解析不是问题,问题在于翻译。 主要.py

from bs4 import BeautifulSoup
from googletrans import Translator

def get_soup(url):
    # Запрос на сайт
    q = requests.get(url)
    result = q.content
    # Экземпляр модуля bs4
    soup = BeautifulSoup(result, 'lxml')

    return soup

def translate_string(string) -> str:
    translator = Translator()
    translation = translator.translate(string, dest='ru')
    return translation.text

def main():
    soup = get_soup('https;//123')
    response = soup.select('div.MuiBox-root.css-0 div')
    text = ''
    text += translate_string(str(i)) for i in response[0]

有必要确保在翻译一行时标签不会被翻译,现在它看起来像这样:

<данные стилей -emotion="css 196imzh">.css-196imzh{стиль-списка:нет;маржа:0;отступ:0;позиция:относительная;отступ-сверху:8px;отступ-снизу:8px;тип-стиля-списка:диск ;padding-left:16px;}.css-196imzh .MuiListItem-root{display:-webkit-box;display:-webkit-list-item;display:-ms-list-itembox;display:list-item;}< /style>

也就是说,您只需翻译文本,而不是标签。我尝试像这样实现,但我的尝试是徒劳的:

    for i in response[0]:
        line = str(i)
        text_in_line = i.get_text()
        translated = transkate_string(i.get_text())
        line = line.replace(text_in_line, translated)
        text += line

因为text_in_line- 这只是文本,没有类型标签<strong>,因此replace没有改变任何东西。
您能告诉我如何实施吗?

python
  • 1 个回答
  • 30 Views
Martin Hope
zrx
Asked: 2022-10-01 07:05:46 +0000 UTC

计算二维数组的一行中的偶数元素[关闭]

  • -1
关闭 这个问题是题外话。目前不接受回复。

仅当您在提出问题之前尝试自己解决问题时,才允许将学习问题作为问题。请编辑问题并指出究竟是什么导致您难以解决问题。例如,请提供您在尝试解决问题时编写的代码

9 天前关闭。

改进问题

有这样一个二维数组

在此处输入图像描述

如何统计每行中偶数元素的个数,以及找到偶数元素最多的数组的行号并分别显示这一行?

c# массивы
  • 1 个回答
  • 39 Views
Martin Hope
zrx
Asked: 2022-05-20 12:23:13 +0000 UTC

字符串转换器

  • 0

我想编写一个函数,根据数字在正确的情况下写一行,例如:

1 сервер
2 сервера
3 сервера
4 сервера
5 серверов
6 серверов
7 серверов
8 серверов
9 серверов
10 серверов
11 серверов
<...>
21 сервер
22 сервера
23 сервера
24 сервера
25 серверов
26 серверов
27 серверов
28 серверов
29 серверов
30 серверов
31 сервер
32 сервера
33 сервера
34 сервера
35 серверов
<...>
110 серверов
111 серверов
115 серверов
121 сервер
122 сервера

到目前为止,关于如何实现这一点的想法为 0,因为取决于数十和数百,结局总是不同的。
请帮帮我。

python
  • 1 个回答
  • 10 Views
Martin Hope
zrx
Asked: 2022-08-08 21:29:42 +0000 UTC

HTML/CSS | 展开-折叠列表

  • 1

有这个块:

在此处输入图像描述

html代码(样式我就不贴了,代码太多):

<div>
    <div>SERVER MANAGEMENT</div>
</div>
<ul>
    <a>Приветствия</a>
    <a>Модератор</a>
    <a>Реакции с ролями</a>
</ul>

有必要让它在您单击它SERVER MANAGEMENT список ul时折叠,当您再次单击它时,它会展开。

如何实施?

html
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5