有没有办法获取一个页面的所有请求的 url?例如,当我访问一个站点时,浏览器会向服务器发出多个网络请求,例如 html、css 和显示该页面所需的其他文件。我想使用 Python 获取所有这些 Assets url。基本上,我想从下面的屏幕截图中获取所有网址。谁能指出我正确的方向?
PS:我想通过脚本来自动执行此任务。我知道我可以使用无法自动化的 Wireshark 完成此类任务。
最佳答案
对于其他感兴趣的人:下一个片段,我从 a post from pythoncode 得到的,为我工作。
我确信它有一些如上所述的限制(不同的浏览器、不同的路径等,使得这个 hack 不通用),但它可能会节省一些人的时间。
# get the CSS files
css_files = []
for css in soup.find_all("link"):
if css.attrs.get("href"):
# if the link tag has the 'href' attribute
css_url = urljoin(url, css.attrs.get("href"))
css_files.append(css_url)
print(css_files) # list of URLs of the files called
https://stackoverflow.com/questions/37264761/
相关文章:
ios - UIPageViewController 不允许识别 UIScreenEdgePanGe
python - NoReverseMatch 在/accounts/signup/django-a
objective-c - 自定义 UIButton 焦点在 tvOS 中无法正常工作
amazon-web-services - AWS API Gateway 默认响应和触发器 AWS
c# - Asp.Net Web Api 在 Godaddy 服务器上不工作,但在本地工作正常
ios - 如何通过gcdwebserver获取本地html文件
android - CardView 内的 ExpandableListView 不会改变其父级高度