简体   繁体   中英

Python grab headers requests

it's any way to grab all headers requests from site, which loads in browser network tool (maybe selemium)?

I need this URL 在此处输入图片说明

Try this code and let me know in case of any issues:

links = []
for element in driver.find_elements_by_xpath('//head/*[@href or @src]):
    link = element.get_attribute("href")
    links.append(element.get_attribute("href")) if link != '' else links.append(element.get_attribute("src")) 

To get links from iframes also you might need to add this :

for frame in driver.find_elements_by_tag_name('iframe'):
    driver.switch_to_frame(frame)
    for element in driver.find_elements_by_xpath('//head/*[@href or @src]):
        link = element.get_attribute("href")
        links.append(element.get_attribute("href")) if link != '' else links.append(element.get_attribute("src"))
    driver.switch_to_default_content()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM