Reputation: 1126
I open a Chrome Devtools and choose Network tab. Then I can choose "Copy link address" if I right-click on some file (they are image files in my case) in the request list. I want to get their addresses in one click (or as easy as possible). Is there a good way or a workaround for that?
Upvotes: 4
Views: 6859
Reputation: 131
click"Copy" >> "Copy all as HAR"
on any item in the network tab (preferably under URL column but it shouldn't matter).
go to console, below and place the cursor. you will be typing something there now.
type ```a=
you have stored the clipboard in a variable just now.
press enter
type copy(a.log.entries.map(e => e.request.url).join('\n'))
and press enter
check your clip board.
if you are too lazy for all that you could just run a .py script like this:
import csv , os, sys, json
import pyperclip
output_file = 'output.csv'
sdata = pyperclip.paste()
try:
j = json.loads(sdata)
except Exception as ex:
print(f'Exception .. {ex}')
sys.exit()
entries = j.get('log').get('entries')
allurls = [entry.get('request').get('url') for entry in entries]
with open(output_file, 'w', newline='', encoding='UTF-8') as fp:
writer = csv.writer(fp)
for url in allurls:
writer.writerow([url])
print(f'output file {output_file} created for {len(allurls)} URLS!')
Upvotes: 2