【发布时间】:2019-01-04 21:22:32
【问题描述】:
我正在尝试抓取下面链接左下角图表中显示的评级趋势数据,但似乎无法找到获取它的方法。我担心这是因为它是作为图片嵌入的,因此无法访问数据,但我想我会检查一下。
添加了我拼接在一起的代码,但我只得到了轴值。
任何帮助将不胜感激。
https://www.glassdoor.com/Reviews/Netflix-Reviews-E11891.htm#trends-overallRating
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from time import sleep
import pandas as pd
from selenium.webdriver.common import action_chains, keys
from selenium.common.exceptions import NoSuchElementException
import numpy as np
import sys
import re
import warnings
options = Options()
options.headless = True
driver = webdriver.Chrome(r'PATH',options=options)
driver.get('https://www.glassdoor.com/Reviews/Netflix-Reviews-E11891.htm#trends-overallRating')
trend_element = driver.find_elements_by_xpath('//*[@id="DesktopTrendChart"]')[0]
trend = trend_element.text
print(trend)
【问题讨论】:
-
你说得对,看起来数据是在
svg图像中呈现的,但也许可以从 svg 数据中提取值。知道您希望如何表示数据输出吗? -
老实说,我会尽我所能,但如果我能将日期和值放在一起,那将是一个巨大的帮助。真的只是在寻找每个日期的值。
-
是的,这很棘手。你可以得到我在那里看到的日期,但相应的值你必须做一些工作。这条线是由 x 和 y 坐标(在那里)绘制的,但是你必须以某种方式对其进行缩放。即便如此,它看起来也只是估计值。我认为锻炼/做起来真的很难/很复杂,但获得相对接近的东西并非不可能
-
其实想了想,明天有时间再试一下。我有一些想法可以尝试,实际上提取这些信息应该不会太难。
-
不是程序化解决方案,可能会解决您的问题WebPlotDegitizer
标签: python selenium web-scraping