【发布时间】:2019-04-23 10:22:30
【问题描述】:
我正在测试下面的代码。
from bs4 import BeautifulSoup
import requests
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
import time
browser = webdriver.Firefox(executable_path="C:/Utility/geckodriver.exe")
wd = webdriver.Firefox(executable_path="C:/Utility/geckodriver.exe", firefox_profile=profile)
url = "https://corp_intranet"
wd.get(url)
# set username
time.sleep(2)
username = wd.find_element_by_id("id_email")
username.send_keys("my_email@corp.com")
# set password
password = wd.find_element_by_id("id_password")
password.send_keys("my_password")
url=("https://corp_intranet")
r = requests.get(url)
content = r.content.decode('utf-8')
print(BeautifulSoup(content, 'html.parser'))
这可以很好地登录我的公司内部网,但它只是打印非常非常基本的信息。点击 F12 显示页面上的很多数据都是使用 JavaScript 呈现的。我对此做了一些研究,并试图找到一种方法来真正抓住我在屏幕上看到的东西,而不是我能看到的非常非常稀释的版本。有没有办法对页面上显示的所有数据进行大数据转储?谢谢。
【问题讨论】:
-
这听起来像是X-Y problem。与其寻求解决问题的帮助,不如编辑您的问题并询问实际问题。你想做什么?
标签: python python-3.x selenium geckodriver