【问题标题】:Parsing through the HTML and scripts on a webpage using python?使用python解析网页上的HTML和脚本?
【发布时间】:2014-11-28 23:52:20
【问题描述】:

我目前正在使用 Beautiful Soup 来解析网页的 HTML。但是,我也想递归解析网页上的任何 .js 文件。我的目标是查找嵌入在网站的 HTML 或 javascript 中的某些 URL。我可以用基本的 HTML 页面来做,但是进入 javascript 文件让我很难过。有什么帮助吗?

【问题讨论】:

标签: javascript python html


【解决方案1】:

按照this StackOverflow question 接受的答案中概述的步骤进行操作。然后,您可以使用例如优秀的requests library 来请求资源:

import requests

r = requests.get("http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js")

然后您可以搜索 r.text using regex 以找到您正在寻找的任何链接。

如果您仍需要解析 javascript,那么在您拥有 javascript 后,this StackOverflow question 的最新回答建议使用 slimit

【讨论】:

    猜你喜欢
    • 2011-08-09
    • 2020-08-11
    • 2013-07-01
    • 2020-09-02
    • 2015-09-08
    • 2014-07-05
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    相关资源
    最近更新 更多