Похожие чаты

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 ответов

13 просмотров

!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

maron- Автор вопроса

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

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

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

30 BCH videos in Hausa Language successfully delivered. In December 2023, I created a Flipstarter to produce Bitcoin Cash videos in the Hausa language for greater outreach an...
Munnir
5
читать файл максимально быстро? странный вопрос))
zamtmn
53
тоесть, указав return eax, сгенерируется никому ненужная инструкция mov eax,eax ?
Aiwan \ (•◡•) / _bot
24
Посоветуйте пожалуйста аудио плеер для библиотеки mp3- FLAC на компьютере. На Винде пользовался Aimp, в том числе для конвертации. Много нужных команд было прямо в контекст...
Виктор Кузнецов
31
Hi guys , do we have update on voting?
HB
15
How Much Btc Falling Down ?
Suriya
22
Why build it new? Why not try and get projects like fjord foundry etc. to launch? There is more power in getting real adoption and other teams on than to start everything a ne...
Qrayon Shinchan
11
ᴅᴏ ʏᴏᴜ ᴋɴᴏᴡ ᴛʜᴀᴛ ʏᴏᴜ ᴄᴀɴ ꜱᴇᴄᴜʀᴇ ᴀ ᴍᴀꜱꜱɪᴠᴇ ꜰɪɴᴀɴᴄɪᴀʟ ꜰᴜᴛᴜʀᴇ ʙʏ ᴊᴏɪɴɪɴɢ ᴛʜᴇ ᴏɴ ɢᴏɪɴɢ Qᴜᴀɴᴛᴜᴍ_ᴀɪ_ʀᴏʙᴏᴛ ᴛʀᴀᴅɪɴɢ ʙʏ ᴇʟᴏɴ ᴍᴜꜱᴋ? 👇👇👇JOIN NOW https://t.me/+3Ii7e3UQKRpiZjZk https://t...
Niklas Orlowski
3
It is definitely an interesting conversation. Breaking up the users into 2 personas: 1. Someone who wants to use the products (I want “x” pegged stablecoin that provides safe...
Bueno Pues
10
Hi guys ! Anvil is out ! Time for me to stake on capacity. Does someone has a clear tutorial ? I’m thinking about buying a ledger. Is that really possible to stake directl...
Mister Grega
15
Карта сайта