1

My df needs to have raw text, but the result i am getting comes inside brackets.

Here is my code:

    chatroom = driver.find_element_by_class_name('_1_q7u')
    pos= 0
    df = pd.DataFrame(columns=['Msgs','Time'], index=None)
    chat = driver.find_element_by_class_name('_19vo_').text
    for ol in chatroom.find_elements_by_class_name('message-in'):
        msgs = [k.text for k in ol.find_elements_by_class_name('_12pGw')]
        times = [k.text for k in ol.find_elements_by_class_name('_1RNhZ')]
        # df = [msgs,times]
        df.loc[pos] = [msgs, times]
        pos+=1
        print(df)

Here is the output i have:

       Msgs     Time
0       [T]  [14:30]
1       [Z]  [14:36]
2       [Q]  [14:37]
3       [R]  [14:39]

Here is the output i want:

       Msgs     Time
0       T     14:30
1       Z     14:36
2       Q     14:37
3       R     14:39

0

1 Answer 1

2
chatroom = driver.find_element_by_class_name('_1_q7u')
pos= 0
df = pd.DataFrame(columns=['Msgs','Time'], index=None)
chat = driver.find_element_by_class_name('_19vo_').text
for ol in chatroom.find_elements_by_class_name('message-in'):
    msgs = [k.text for k in ol.find_elements_by_class_name('_12pGw')][0]
    times = [k.text for k in ol.find_elements_by_class_name('_1RNhZ')][0]
    # df = [msgs,times]
    df.loc[pos] = [msgs, times]
    pos+=1
    print(df)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.