简体   繁体   English

我如何让python使用firefox插件从本地文件下载图像

[英]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.

相关问题 如何使用Python触发从网站下载文件? - How do I use Python to trigger the download of a file from a website? 从 CSV 中的 Urls 下载图像到本地文件夹 Python 中的文件 - Download Images to Local Folder from Urls in CSV file in Python 如何将文件下载到本地目录 - How do I download file to local directory 如何在Python中从本地服务器下载文件 - How to download file from local server in Python 如何使用python从带有签名和有效期的链接中下载S3文件? - How do I use python to download an S3 file from a link with a signature and expiration? Python:如何让 Firefox 首选项自动下载 .eml 文件? - Python: How can I get Firefox preferences to automatically download a .eml file? 如何使用 Python 和 lxml 解析本地 html 文件? - How do I use Python and lxml to parse a local html file? 使用Selenium和Firefox版本40,我如何下载文件? - Using Selenium and Firefox version 40, how do i download a file? 如何从 url 列表中抓取图像并将其下载到本地文件夹? - How to I scrape images from a list of urls and download it to local folder? 如何使用python中另一个函数的局部变量? - How do I use local variables from another function in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM