我真的在尽我最大的努力找到一种方法来使用 javascript 来加载网页来抓取网站,这样我就可以抓取比如我的播放列表。我对 chrome 驱动程序和 phantomjs 都没有运气。请在下面查看,看看您是否可以帮助我解决错误。
using OpenQA.Selenium;
//The type or namespace 'PhantomJS' does not exist in the namespace 'OpenQASelenium'
using OpenQA.Selenium.PhantomJS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MusicScaper
{
class TidalScraper
{
}
}
我的 packages.config 文件如下:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HtmlAgilityPack" version="1.8.7" targetFramework="net461" />
<package id="PhantomJS" version="2.1.1" targetFramework="net461" />
<package id="Selenium.Support" version="3.14.0" targetFramework="net461" />
<package id="Selenium.WebDriver" version="3.14.0" targetFramework="net461" />
</packages>
最佳答案
.NET 语言绑定(bind)标记了 PhantomJS 驱动程序类在 3.11 中已弃用,并且这些类在 3.14 中被删除。 PhantomJS 项目及其驱动程序不再维护,驱动程序代码尚未(也不会)更新以支持 W3C WebDriver 规范。首选的“ headless ”解决方案是在 headless 模式下使用 Chrome 或 Firefox,因为这两种浏览器及其驱动程序都支持这种操作模式。或者,如果您对 PhantomJS 有兴趣,并且不关心跨浏览器执行,您可以简单地使用 PhantomJS 可执行文件并通过其内部 JavaScript API 将其自动化。
关于c# - Selenium.PhantomJS 是无效的命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52442100/