Похожие чаты

Following script must copy all text from each opened tabs

in firefox, but after 5 or 10 tab jump to latest tab, how to fix this?

import pyautogui
import pyperclip
import time

def copy_text_from_tabs(num_tabs, output_file):
# Delay to ensure you have time to focus on Firefox
print("Please focus on Firefox within the next 5 seconds...")
time.sleep(5)

# List to store the text from each tab
tab_texts = []

# Loop through the number of tabs specified
for tab_num in range(1, num_tabs + 1):
# Switch to the tab
pyautogui.hotkey('ctrl', str(tab_num))

# Delay to allow time for the page to load
time.sleep(1)

# Select all text, copy, and append to the list
pyautogui.hotkey('ctrl', 'a')
pyautogui.hotkey('ctrl', 'c')
tab_text = pyperclip.paste()

tab_texts.append(f"Tab {tab_num}:\n{tab_text}\n{'/' * 25}\n") # Add separators between tab texts

# Join all the tab texts
all_text = '\n'.join(tab_texts)

# Save the text to the output file
with open(output_file, 'w', encoding='utf-8') as file:
file.write(all_text)

if name == "main":
num_tabs_to_copy = 20 # Change this number to the desired number of tabs
output_file_name = "all_tabs_text.txt"

copy_text_from_tabs(num_tabs_to_copy, output_file_name)

8 ответов

34 просмотра

!paetebin

!paste

To post more than a few lines of code, use a pastebin like: * dpaste.org * linkode.org * bin.kv2.dev * hastebin.com If you are stuck in a terminal, you can use ix.io or paste.rs to paste from the CLI: <command to print output> |& curl -F 'f:1=<-' ix.io <command to print output> |& curl --data-binary @- https://paste.rs

you can add a condition to check whether the current tab number is a multiple of 5 or 10. If it is, then switch to the latest tab before proceeding to the next iteration

I guess your problem is that, instead of going to the 9th tab your code goes to the last tab. That's because "Ctrl - 9" is the shortcut for the last tab not the 9th tab. Instead switch tabs with "Ctrl - Tab"

maron- Автор вопроса
Yiğit Can
I guess your problem is that, instead of going to ...

can you tell me what change i must apply to my script?

maron
can you tell me what change i must apply to my scr...

Where you're iterating with tab_num, that's where you should ctrl+tab

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта