Open tttollerer opened 8 months ago
This is how it seems to work across different channels and languages:
145 messages = await page.query_selector_all("[class='messageListItem']") 154 image_elements = await page.query_selector_all("[class='originalLink']") 185 pill_value_locator = "span[class='optionPillValue']" 258 messages = await page.query_selector_all("[class='messageListItem']") 395 chat_bar = page.locator("div[role='textbox'][aria-label^='Message #']") 404 prompt_option_selector = "#autocomplete-0"
There are various problems with the DOM addressing, e.g. if the Discord client is not set to English or the channel was not created by an English client.
This affects the following lines, for example:
145 messages = await page.query_selector_all(".messageListItem-ZZ7v6g") 154 image_elements = await page.query_selector_all('.originalLink-Azwuo9') 185 pill_value_locator = 'span.optionPillValue-2uxsMp' 258 messages = await page.query_selector_all(".messageListItem-ZZ7v6g") 395 chat_bar = page.get_by_role('textbox', name='Message #general') 404 prompt_option_selector = "#autocomplete-0 > .base-2v-uc0"
Unfortunately, there also seems to be no solution to provide the classes with whitespaces like 404 prompt_option_selector = "#autocomplete-0 > .base-2v-uc0" -> prompt_option_selector = "#autocomplete-0 > [class^='base']"
I think you have to go through the position in the DOM.