1

So I am pretty dang new to this type of stuff, so I do not know the right words for most of this, but I'll try and give as much details, so somebody can correct me.

When I open inspect element on Chrome, and switch to the "Network" Tab, then visit a website, a ton of items show up in a list here (I don't know what to refer to this page as or the list of things as)

When I visit a website, and I am wanting my program to go through this list of items, and if an item is of Type: "Media" and the name starts with "ABC" I want to copy the link to where it's located. Is this something that's possible with Selenium?

blake
  • 59
  • 5

1 Answers1

0

Basic Words:

  • Inspect Element => Devtools
  • List (in Network Tab) => Requests

Here is a small snippet that shows all the URLs for the requests that start with ABC:

from selenium import webdriver

# create a session
driver = webdriver.Chrome()
# go to the url
driver.get("https://stackoverflow.com/")
# create script that will return network requests
networkScript = """
var performance = window.performance || window.webkitPerformance || {};
var network = performance.getEntries() || {};
return network;
"""
# run the js script and save the result
networkRequests = driver.execute_script(networkScript)
# get the request URL
URLs = [request['name'] for request in networkRequests if request['name'].split("/")[-1].startswith("ABC")]
# your logic on what to do if request is found
print(URLs)

My answer is inspired by @Shubham Jain's answer