因爲工作原因,我在使用「driver = webdriver.PhantomJS()」之前能夠刮掉以下網站。我所刮的是價格和日期。如何在刮網站時繞過免責聲明
https://www.cash.ch/fonds/swisscanto-ast-avant-bvg-portfolio-45-p-19225268/swc/chf
這停止工作前幾天,由於我有起初同意免責聲明頁面。
一旦同意我看到視覺的真實內容,但司機好像不是,打印出來是[],所以它必須與聲明的網址是仍。
請參閱下面的代碼。
from selenium import webdriver
from bs4 import BeautifulSoup
import csv
import os
driver = webdriver.PhantomJS()
driver.set_window_size(1120, 550)
#Swisscanto
driver.get("https://www.cash.ch/fonds/swisscanto-ast-avant-bvg- portfolio-45-p-19225268/swc/chf")
s_swisscanto = BeautifulSoup(driver.page_source, 'lxml')
nav_sc = s_swisscanto.find_all('span', {"data-field-entry": "value"})
date_sc = s_swisscanto.find_all('span', {"data-field-entry": "datetime"})
print(nav_sc)
print(date_sc)
print("Done Swisscanton")
試圖找出是否免責聲明設置任何cookie,並做這之前刮。你應該檢查你是否遵守免責聲明,因爲它是有原因的 – Marged
嗨Marget,你可以進一步解釋如何檢查是否免責聲明設置任何cookie?謝謝。 – Shanshan
請看看我的代碼,真的很短,只是添加到帖子。 – Shanshan