Изменение таблицы Confluence с помощью Python и Beautiful SoupPython

Программы на Python
Гость
Изменение таблицы Confluence с помощью Python и Beautiful Soup

Сообщение Гость »


Здравствуйте, я пытаюсь автоматически изменить таблицу слияния (добавить новую строку) с помощью Python каждый раз, когда запускается мой код Python. Мне удалось подключиться к API Confluence, получить тело страницы Confluence и найти целевую таблицу. Затем я взял этот текст JSON и нашел таблицы, когда преобразовал их в фрейм данных, чтобы добавить новые данные (строку), в фоновом режиме также происходят вычисления. Затем я сохранил эту таблицу данных обратно в HTML, и здесь у меня возникли проблемы с заменой старой таблицы HTML на новую таблицу HTML, которая у меня есть.

Код: Выделить всё

# This is JSON payload from confluence API
response_text_json = json.loads(response_text)

This is the value of the contents of the confluence API
table_value = response_text_json['body']['storage']['value']

soup = bs.BeautifulSoup(table_value, "html.parser")
tables = soup.find_all("table") # should only contain 3 tables

# this is the table I am replacing with table (appended row)
df_main = pd.read_html(str(tables))[2]

# Data Manipulations sections #

df_main.loc[len(df_main)] = ['Data', 'Data', 'Data']

str_df_main = df_main.to_html(index=False)

tables[2].string = str_df_main

soup = str(soup)

## injecting it back to confluence using PUT

I was able to find the table needed to modify and append the new data and convert it back to html but when I update the confluence page it returns the actual HTML string of the new datatable and not the table.
Can you help me what I did wrong here? Apologies, I am new handling HTML tags


Источник: https://stackoverflow.com/questions/781 ... tiful-soup

Вернуться в «Python»