【问题标题】:python web scraping. Site not showing only a few script tags. Have tried opening with selenium driver browserpython网页抓取。站点未仅显示几个脚本标签。试过用 selenium 驱动浏览器打开
【发布时间】:2020-05-12 10:02:41
【问题描述】:

我正试图从这个site 中提取价格。 我首先尝试使用 beautifulsoup,然后使用 selenium webdriver 浏览器打开页面,但得到了这个响应。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="about:blank">
</head>
<body>
<script src="/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/j.js"></script>
<script src="/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/f.js"></script>
<script src="/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/fingerprint/script/kpf.js?url=/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/fingerprint&token=9d98d39f-e497-2d15-7332-7e21738bd6e2"></script>
</body>
</html>

这是我的python代码。

from selenium import webdriver

dove_coles_url = "https://shop.coles.com.au/a/churchill-centre/product/dove-antiperspirant-deodorant-invisible-dry"
PATH = "C:\\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.delete_all_cookies()
driver.get(dove_coles_url)

提前致谢。

【问题讨论】:

    标签: python selenium web-scraping beautifulsoup


    【解决方案1】:

    使用浏览器控制台,在网络选项卡中,您可以看到正在发出的请求:

    https://shop.coles.com.au/search/resources/store/20509/productview/bySeoUrlKeyword/dove-antiperspirant-deodorant-invisible-dry?catalogId=17056

    打开它,您会看到它包含该产品的所有 json 数据。

    【讨论】:

      猜你喜欢
      • 2021-02-11
      • 1970-01-01
      • 1970-01-01
      • 2021-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多