Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 显示隐藏的web表_Python_Html_Selenium - Fatal编程技术网

Python 显示隐藏的web表

Python 显示隐藏的web表,python,html,selenium,Python,Html,Selenium,我正试图擦桌子,但似乎看不见 在您以浅紫色展开“代码历史记录”部分后,此表位于此位置。登录凭据如下所示,但也很容易从试用帐户获得: 用户名=jd@mailinator.com 密码=m%$)-Y95*^.1英寸+ 下面是我试图获取的数据的图示。我对最下面一行感兴趣: 以下是我使用的代码: from selenium import webdriver driver_path = "path to chromedriver.exe" url_login = "https://www.finda

我正试图擦桌子,但似乎看不见

在您以浅紫色展开“代码历史记录”部分后,此表位于此位置。登录凭据如下所示,但也很容易从试用帐户获得:

  • 用户名=jd@mailinator.com
  • 密码=m%$)-Y95*^.1英寸+
下面是我试图获取的数据的图示。我对最下面一行感兴趣:

以下是我使用的代码:

from selenium import webdriver
driver_path = "path to chromedriver.exe"
url_login = "https://www.findacode.com/signin.html"
url_code = "https://www.findacode.com/code.php?set=CPT&c="
username = 'jd@mailinator.com'
password = 'm%$)-Y95*^.1Gin+'

options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options)

driver.get(url_login)
form = driver.find_element_by_name('login')
form.find_element_by_name('id').send_keys(username)
form.find_element_by_name('password').send_keys(password)
form.find_element_by_xpath("//input[@value='Sign In']").submit()

driver.get(url_code+'0001U')
driver.find_element_by_id('history').click()

此时,当我查看
driver.page\u source
时,我希望表中的元素是可见的,但事实并非如此。我的想法中的缺陷在哪里?

此站点在需要时加载页面片段(也称为延迟加载)。因此,当页面的该部分展开时,将加载实际内容。这有助于在“试用期”到期时,服务器可以返回通用内容,以防止未经授权的访问

我可以找到3种补救方法:

  • 等待数据在
    #历史记录之后可用。单击()
    ,然后加载内容div(在
    之后)。sectionbody
    div不为空)
  • 登录后直接调用相同的URL,从片段中获取数据。i、 e.
    .get(“https://www.findacode.com/logs/codepage_stats.php?section=sh_history_div&set=CPT&c=0001U“”
  • 利用其内置的自动打开功能,我只需检查一次相应的复选框,然后在将来的请求中加载您通常期望的所有数据

  • 感谢试图屏蔽密码的用户,但我打算共享密码,因为该帐户是为测试而创建的,登录凭据是查看问题所必需的。谢谢。我将从选项3开始尝试这些方法,看看效果如何。