[英]How do I get python to use a firefox addon to download images from a local file
I am trying to get python to open a local html file in firefox and then use a addon called "download all" to download the images to a specific folder. 我正在尝试让python在firefox中打开本地html文件,然后使用名为“全部下载”的插件将图像下载到特定文件夹。 I am not able to scrape them for some weird reason. 由于某些奇怪的原因,我无法将它们抓取。 If I can't do it this way I would want to use xpath to do it since the image links are laid out in tables. 如果我不能以这种方式做到这一点,那我将要使用xpath来实现,因为图像链接被布置在表格中。 Is this possible? 这可能吗?
You can't click on the element since it's not a web page element. 您不能点击该元素,因为它不是网页元素。 However you can create a profile for firefox and include addons in that profile that is launched by the webdriver applications. 但是,您可以为firefox创建配置文件,并在由webdriver应用程序启动的配置文件中包含插件。 This will allow you to have access to Firebug or other addons. 这样您就可以访问Firebug或其他插件。 you can set a profile and extend the profile with the addon api is like so: 您可以设置配置文件并使用addon api扩展配置文件,如下所示:
File file = new File("addonName.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.addOn.currentVersion", "1.8.1"); // Avoid startup screen
WebDriver driver = new FirefoxDriver(firefoxProfile);
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.