0 / 0 / 0
Регистрация: 24.10.2015
Сообщений: 142
|
|||||||||||
1 | |||||||||||
'Str' object is not callable21.05.2022, 13:16. Показов 451. Ответов 4
Метки нет (Все метки)
Форумчане, привет!
Извлекаю текст из ссылок между тегами a. Выводится сообщение об ошибке:
Подскажите, пожалуйста, где ошибка? Фрагмент html, который я обрабатываю: Кликните здесь для просмотра всего текста
<tr> <td> <div class="flex"> <div class="flex-column pt1 mr3" style="width: 102px;"> <button class="sn-dark-white-button " label="Save" style="margin-bottom: 5px;" type="button"> Save </button> <button class="request-intro-button " type="button"> View </button> </div> <a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/ber-cu" style="height: 102px; width: 102px;"> <div style="position: relative; width: 102px; height: 102px;"> <img alt="Photo" class="humbnail listimage-container" height="102" src="To_files/12.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/> </div> </a> <div class="pt1"> <div class="sn-tor-name-wrapper"> <div class="flex" style="align-items: center;"> <a href="https://bbb.com/fly/be-gs" style="line-height: 12px; margin-bottom: 3px; color: white;"> <strong class="sn-tor-name null"> Ber Cu </strong> </a> </div> <a href="https://bbb.com/firms/third-es"> A-ta-ta </a> <span class="sn-small-link hidden-xs null"> Se Ate </span> </div> </div> </div> </td> <td class="text-center relative"> <span class="text-center" style="cursor: pointer; margin: 0px auto;"> n/a </span> </td> <td class="text-center pt2"> <div class="flex-column"> <div> Black </div> <div class=""> Green 12 </div> </div> </td> <td style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/16.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> It <a href="https://bbb.com/r-lists/top-en-rs"> MA </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-san-rs"> CA </a> </span> </div> </div> </div> </div> </td> <td class="" style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/16.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> It <a href="https://bbb.com/r-lists/top-bi-rs"> Bi </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-di-rs"> Di </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-ho-rs"> Ho Se </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-he-rs"> IT </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-me-rs"> M Di </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-sa-rs"> Other </a> </span> </div> </div> <span class="sn-pill" style="bottom: -5px; right: 0px;"> +3 </span> </div> </div> </td> </tr> <tr> <td> <div class="flex"> <div class="flex-column pt1 mr3" style="width: 102px;"> <button class="sn-dark-white-button " label="Save" style="margin-bottom: 5px;" type="button"> Save </button> <button class="request-intro-button" type="button"> View </button> </div> <a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/au-st" style="height: 102px; width: 102px;"> <div style="position: relative; width: 102px; height: 102px;"> <img alt="Photo" class="thumbnail listimage-container" height="102" src="To_files/133.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/> </div> </a> <div class="pt1"> <div class="sn-tor-name-wrapper"> <div class="flex" style="align-items: center;"> <a href="https://bbb.com/fly/au-st" style="line-height: 12px; margin-bottom: 3px; color: white;"> <strong class="sn-tor-name null"> Au St </strong> </a> </div> <a href="https://bbb.com/f/san-ur"> San V </a> <span class="sn-small-link hidden-xs null"> Si Ass </span> </div> </div> </div> </td> <td class="text-center relative"> <span class="text-center" style="cursor: pointer; margin: 0px auto;"> d/a </span> </td> <td class="text-center pt2"> <div class="flex-column"> <div> G0 1.2 </div> <div class=""> 12 - 14 </div> </div> </td> <td style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/26.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> It <a href="https://bbb.com/r-lists/top-sa-rs"> CA </a> </span> </div> </div> </div> </div> </td> <td class="" style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/26.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> It <a href="https://bbb.com/r-lists/top-di-rs"> Di Ha </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-he-rs"> Ho Se </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-he-rs"> HI </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-me-rs"> Mi Se </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-sa-rs"> Other </a> </span> </div> </div> <span class="sn-pill" style="bottom: -5px; right: 0px;"> +2 </span> </div> </div> </td> </tr> Мой код:
Благодарю.
0
|
21.05.2022, 13:16 | |
Ответы с готовыми решениями:
4
'str' object is not callable Почему? TypeError: 'str' object is not callable TypeError: 'str' object is not callable. Как исправить? TypeError: 'str' object is not callable. Как исправить? - Python Как исправить ошибку TypeError: 'str' object is not callable? |
19509 / 11049 / 2931
Регистрация: 21.10.2017
Сообщений: 23,302
|
|
21.05.2022, 15:16 | 2 |
Сообщение от MaxGal
2
|
0 / 0 / 0
Регистрация: 24.10.2015
Сообщений: 142
|
|
21.05.2022, 18:16 [ТС] | 3 |
Блин...
Это просто усталость: не могу сосредоточиться. И внутренний голос ведь говорил - что-то не то с именем. Блин... И запостил когда, мелькнула мысль: "А почему range в коде зеленым выделило?". Блин... Благодарю. А как организовать корректный вывод в строку? 1.[name1, spot, ran, [text1, text2, text3]] (где text1(2,3,4,5) - текст из ссылок (между тегами a)). 2.[name1, spot, ran, [text1, text2, text3, text4, text5]] и т.д. А то сейчас такое печатает...
0
|
19509 / 11049 / 2931
Регистрация: 21.10.2017
Сообщений: 23,302
|
|
21.05.2022, 18:51 | 4 |
0
|
0 / 0 / 0
Регистрация: 24.10.2015
Сообщений: 142
|
||||||
21.05.2022, 23:24 [ТС] | 5 | |||||
Сорри, я не совсем корректно сформулировал второй вопрос.
Есть один цикл, который извлекает данные между <tr>. Есть второй, цикл, вложенный в этот. Он должен выбирать информацию меду тегами а в блоках <div class="sn-clamp">. Каждый из них по отдельности работает отлично. А когда я их соединяю, они не корректно соединяют данные. Вот мой код:
Кликните здесь для просмотра всего текста
<tr> <td> <div class="flex"> <div class="flex-column pt1 mr3" style="width: 102px;"> <button class="sn-dark-white-button " label="Save" style="margin-bottom: 5px;" type="button"> Save </button> <button class="request-intro-button " type="button"> View </button> </div> <a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/ber-cu" style="height: 102px; width: 102px;"> <div style="position: relative; width: 102px; height: 102px;"> <img alt="Photo" class="humbnail listimage-container" height="102" src="To_files/12.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/> </div> </a> <div class="pt1"> <div class="sn-tor-name-wrapper"> <div class="flex" style="align-items: center;"> <a href="https://bbb.com/fly/be-gs" style="line-height: 12px; margin-bottom: 3px; color: white;"> <strong class="sn-tor-name null"> Data_1.1 </strong> </a> </div> <a href="https://bbb.com/firms/third-es"> Data_1.2 </a> <span class="sn-small-link hidden-xs null"> Data_1.3 </span> </div> </div> </div> </td> <td class="text-center relative"> <span class="text-center" style="cursor: pointer; margin: 0px auto;"> n/a </span> </td> <td class="text-center pt2"> <div class="flex-column"> <div> 1.C1 </div> <div class=""> 1.C1 - C2 </div> </div> </td> <td style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/16.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> In <a href="https://bbb.com/r-lists/top-en-rs"> 1.1.1 </a> , </span> <span> In <a href="https://bbb.com/r-lists/top-san-rs"> 1.1.2 </a> </span> </div> </div> </div> </div> </td> <td class="" style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/16.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> In <a href="https://bbb.com/r-lists/top-bi-rs"> 1,2,1 </a> , </span> <span> In <a href="https://bbb.com/r-lists/top-di-rs"> 1,2,2 </a> , </span> <span> In <a href="https://bbb.com/r-lists/top-ho-rs"> 1.2.3 </a> , </span> <span> In <a href="https://bbb.com/r-lists/top-he-rs"> 1.2.4 </a> , </span> <span> In <a href="https://bbb.com/r-lists/top-me-rs"> 1.2.5 </a> , </span> <span> In <a href="https://bbb.com/r-lists/top-sa-rs"> 1.2.6 </a> </span> </div> </div> <span class="sn-pill" style="bottom: -5px; right: 0px;"> +3 </span> </div> </div> </td> </tr> <tr> <td> <div class="flex"> <div class="flex-column pt1 mr3" style="width: 102px;"> <button class="sn-dark-white-button " label="Save" style="margin-bottom: 5px;" type="button"> Save </button> <button class="request-intro-button" type="button"> View </button> </div> <a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/au-st" style="height: 102px; width: 102px;"> <div style="position: relative; width: 102px; height: 102px;"> <img alt="Photo" class="thumbnail listimage-container" height="102" src="To_files/133.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/> </div> </a> <div class="pt1"> <div class="sn-tor-name-wrapper"> <div class="flex" style="align-items: center;"> <a href="https://bbb.com/fly/au-st" style="line-height: 12px; margin-bottom: 3px; color: white;"> <strong class="sn-tor-name null"> Data_2.1 </strong> </a> </div> <a href="https://bbb.com/f/san-ur"> Data_2.2 </a> <span class="sn-small-link hidden-xs null"> Data_2.3 </span> </div> </div> </div> </td> <td class="text-center relative"> <span class="text-center" style="cursor: pointer; margin: 0px auto;"> d/a </span> </td> <td class="text-center pt2"> <div class="flex-column"> <div> 2.C1 </div> <div class=""> 2.C1 - C2 </div> </div> </td> <td style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/26.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> It <a href="https://bbb.com/r-lists/top-sa-rs"> 2.1.1 </a> </span> </div> </div> </div> </div> </td> <td class="" style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/26.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> It <a href="https://bbb.com/r-lists/top-di-rs"> 2.2.1 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-he-rs"> 2.2.2 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-he-rs"> 2.2.3 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-me-rs"> 2.2.4 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-sa-rs"> 2.2.5 </a> </span> </div> </div> <span class="sn-pill" style="bottom: -5px; right: 0px;"> +2 </span> </div> </div> </td> </tr> <tr> <td> <div class="flex"> <div class="flex-column pt1 mr3" style="width: 102px;"> <button class="sn-dark-white-button" label="Save" style="margin-bottom: 5px;" type="button"> Save </button> <button class="request-intro-button" type="button"> View </button> </div> <a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/ja-ko" style="height: 102px; width: 102px;"> <div style="position: relative; width: 102px; height: 102px;"> <img alt="Photo" class="thumbnail listimage-container" height="102" src="To_files/09.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/> </div> </a> <div class="pt1"> <div class="sn-tor-name-wrapper"> <div class="flex" style="align-items: center;"> <a href="https://bbb.com/fly/ja-ko" style="line-height: 12px; margin-bottom: 3px; color: white;"> <strong class="sn-tor-name null"> Data_3.1 </strong> </a> </div> <a href="https://bbb.com/f/ar-rs"> Data_3.2 </a> <span class="sn-small-link hidden-xs null"> Data_3.3 </span> </div> </div> </div> </td> <td class="text-center relative"> <span class="text-center" style="cursor: pointer; margin: 0px auto;"> n/a </span> </td> <td class="text-center pt2"> <div class="flex-column"> <div> 3.C1 </div> <div class=""> 3.C1 - C2 </div> </div> </td> <td style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/36.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> In <a href="https://bbb.com/r-lists/top-sa-rs"> 3.1.1 </a> , </span> <span> </span> <span> In <a href="https://bbb.com/r-lists/top-se-rs"> 3.1.2 </a> , </span> <span> In <a href="https://bbb.com/r-lists/top-mi-rs"> 3.1.3 </a> </span> </div> </div> <span class="sn-pill" style="bottom: -5px; right: 0px;"> +2 </span> </div> </div> </td> <td class="" style="max-width: 400px;"> <div> <div style="position: relative;"> <div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;"> <iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/366.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1"> </iframe> <div style="position: relative;"> <span> Invest <a href="https://bbb.com/r-lists/top-bi-rs"> 3.2.1 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-co-rs"> 3.2.2 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-di-rs"> 3.2.3 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-he-rs"> 3.2.4 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-he-rs"> 3.2.5 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-me-rs"> 3.2.6 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-ph-rs"> 3.2.7 </a> , </span> <span> It <a href="https://bbb.com/r-lists/top-sa-rs"> 3.2.8 </a> </span> </div> </div> <span class="sn-pill" style="bottom: -5px; right: 0px;"> +5 </span> </div> </div> </td> </tr> Должно выводить так [Data_1.1, Data_1.2, Data_1.3, 1.C1, 1.C1 - C2, [1.1.1, 1.1.2]] [Data_2.1, Data_2.2, Data_2.3, 2.C1, 2.C1 - C2, [2.1.1]] [Data_3.1, Data_3.2, Data_3.3, 3.C1, 3.C1 - C2, [3.1.1, 3.1.2. 3.1.3]] Каждый цикл в отдельности выводит данные правильно (если закомментить строки и посмотреть). А совместно выводит так: ['\n Data_3.1\n ', '\n Data_3.2\n', '\n Data_3.3\n', '\n 3.C1\n', '\n 3.C1 - C2\n ', ['\n 1.1.1\n', '\n 1.1.2\n', '\n 2.1.1\n ', '\n 3.1.1\n ', '\n 3.1.2\n', '\n 3.1.3\n ']] Наверное, что-то с вложенностью цикла. Уже и так и сяк пробовал. Не хватает опыта.
0
|
21.05.2022, 23:24 | |
21.05.2022, 23:24 | |
Помогаю со студенческими работами здесь
5
Внезапный лишний аргумент: str ('str' object has no attribute 'Name') 'int' object is not callable 'dict' object is not callable 'float' object is not callable TypeError: 'int' object is not callable Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |
|
Опции темы | |
|
Новые блоги и статьи | |||||
Как проводить научные вычисления на Python
InfoMaster 15.01.2025
Python стал одним из наиболее востребованных языков программирования в области научных вычислений благодаря своей простоте, гибкости и обширной экосистеме специализированных библиотек. Научные. . .
|
Создание игры типа Minecraft на PyGame/Python: пошаговое руководство
InfoMaster 15.01.2025
В данном руководстве мы рассмотрим процесс создания игры в стиле Minecraft с использованием библиотеки PyGame на языке программирования Python. Этот проект идеально подходит как для начинающих. . .
|
Как создать свою первую игру в стиле Doom на Unreal Engine
InfoMaster 15.01.2025
Разработка шутера от первого лица в стиле классического Doom представляет собой увлекательное путешествие в мир игрового программирования, где сочетаются творческий подход и технические навыки. . . .
|
Параллельное программирование: основные технологии и принципы
InfoMaster 15.01.2025
Введение в параллельное программирование
Параллельное программирование представляет собой фундаментальный подход к разработке программного обеспечения, который позволяет одновременно выполнять. . .
|
Как написать микросервис на C# с Kafka, MediatR, Redis и GitLab CI/CD
InfoMaster 15.01.2025
В современной разработке программного обеспечения микросервисная архитектура стала стандартом де-факто для создания масштабируемых и гибких приложений. Этот подход позволяет разделить сложную систему. . .
|
Что такое CQRS и как это реализовать на C# с MediatR
InfoMaster 15.01.2025
Концепция CQRS и её роль в современной разработке
В современном мире разработки программного обеспечения архитектурные паттерны играют ключевую роль в создании масштабируемых и поддерживаемых. . .
|
Как настроить CI/CD с Azure DevOps
InfoMaster 15.01.2025
CI/ CD, или непрерывная интеграция и непрерывное развертывание, представляет собой современный подход к разработке программного обеспечения, который позволяет автоматизировать и оптимизировать процесс. . .
|
Как настроить CI/CD с помощью Jenkins
InfoMaster 15.01.2025
Введение в CI/ CD и Jenkins
В современной разработке программного обеспечения непрерывная интеграция (CI) и непрерывная доставка (CD) стали неотъемлемыми элементами процесса создания качественных. . .
|
Как написать микросервис на Go/Golang с Kafka, REST и GitHub CI/CD
InfoMaster 14.01.2025
Определение микросервиса, преимущества использования Go/ Golang
Микросервис – это архитектурный подход к разработке программного обеспечения, при котором приложение состоит из небольших, независимо. . .
|
Как написать микросервис с нуля на C# с RabbitMQ, CQRS, Swagger и CI/CD
InfoMaster 14.01.2025
В современном мире разработки программного обеспечения микросервисная архитектура стала стандартом де-факто для создания масштабируемых и гибких приложений. Этот архитектурный подход предполагает. . .
|
Как создать интернет-магазин на PHP и JavaScript
InfoMaster 14.01.2025
В современном мире электронная коммерция стала неотъемлемой частью бизнеса. Создание собственного интернет-магазина открывает широкие возможности для предпринимателей, позволяя достичь большей. . .
|
Как написать Тетрис на Ассемблере
InfoMaster 14.01.2025
Тетрис – одна из самых узнаваемых и популярных компьютерных игр, созданная в 1984 году советским программистом Алексеем Пажитновым. За прошедшие десятилетия она завоевала симпатии миллионы людей по. . .
|