Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.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,Selenium“::“之后”;刮削时的问题_Python_Selenium_Selenium Webdriver_Web Scraping_Beautifulsoup - Fatal编程技术网

Python,Selenium“::“之后”;刮削时的问题

Python,Selenium“::“之后”;刮削时的问题,python,selenium,selenium-webdriver,web-scraping,beautifulsoup,Python,Selenium,Selenium Webdriver,Web Scraping,Beautifulsoup,我正试图从动态数据库中获取汽车信息。但是,在运行Selenium chrome浏览器后,检查元素不会像在原始源页面中那样显示。html源代码中显示“::after”元素,而不是汽车详细信息(产品图像附近的信息区域)的html代码 你可以在下面看到我的抓取代码 import requests from requests import get from bs4 import BeautifulSoup from selenium import webdriver driver_path = ("

我正试图从动态数据库中获取汽车信息。但是,在运行Selenium chrome浏览器后,检查元素不会像在原始源页面中那样显示。html源代码中显示“::after”元素,而不是汽车详细信息(产品图像附近的信息区域)的html代码

你可以在下面看到我的抓取代码


import requests
from requests import get
from bs4 import BeautifulSoup
from selenium import webdriver

driver_path = ("C:\\Desktop\\chromedriver.exe")
driver = webdriver.Chrome(driver_path)
driver.get('https://www.arabam.com/ilan/galeriden-satilik-citroen-c-elysee-1-6-hdi-attraction/fiat-onkol-oto-dan-c-elysee-1-6-attraction-92-hp-beyaz/14046287')
soup = BeautifulSoup(driver.page_source, 'html.parser')
table = soup.table

table_rows = table.find_all('li')
print(table_rows)

当我使用给定的代码从网页中获取相关信息时,我看不到任何html属性,这是进一步刮取循环所必需的

这个问题的原因是什么?我该如何解决

谢谢

编辑

selenium浏览器中的HTML元素内容

我尝试访问的普通Google Chrome HTML元素内容


您提供的HTML页面中没有表格,请尝试使用其他选择器。你可以试着通过

driver.find_elements_by_class_name("w100 semi-bold lh18")

这将为您提供一个有序的
span
元素列表

如果您提供的HTML页面中没有表格,请尝试使用其他选择器。你可以试着通过

driver.find_elements_by_class_name("w100 semi-bold lh18")

这将为您提供一个有序的
span
元素列表

您能给我们一个预期输出的示例吗?对于BS,您不能这样做,您需要从浏览器runtime.value=driver.execute\u脚本(“return window.getComputedStyle(document.querySelector('div.row'),':after')。getPropertyValue('content'))---------------------------我尝试了那个,并返回了null值,该值与selenium浏览器中显示的内容完全相同。然而,我试图达到正常的铬检查值。我认为这是在java脚本代码运行之后创建的。在抓取之前,我必须在selenium浏览器中运行此java脚本代码。您能给我们提供预期输出的示例吗?使用BS无法做到这一点,您需要使用浏览器runtime.value=driver.execute_脚本(“return window.getComputedStyle(document.querySelector('div.row'),':after')。getPropertyValue('content'))---------------------------我尝试了那个,并返回了null值,该值与selenium浏览器中显示的内容完全相同。然而,我试图达到正常的铬检查值。我认为这是在java脚本代码运行之后创建的。在抓取之前,我必须在selenium浏览器中运行这个java脚本代码。