Phantomjs Linux下启动报错

在Ubuntu22.04环境下,安装PhantomJS后遇到Autoconfiguration失败的错误,原因是系统找不到libproviders.so文件。通过将OPENSSL_CONF环境变量设置为/etc/ssl,成功解决了问题,使得PhantomJS能正常运行并显示版本为2.1.1。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境为Unbuntu 22.04,安装完phantomjs后验证安装时报如下错误:

cj@vm-ubuntu:/usr/local/bin$ phantomjs --version
Auto configuration failed
140372441778112:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libproviders.so): libproviders.so: cannot open shared object file: No such file or directory
140372441778112:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
140372441778112:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=providers, path=providers
140372441778112:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=providers

解决方法:在环境变量中加入如下值,使phantomjs能够找到指定的文件

export OPENSSL_CONF=/etc/ssl

再次验证后没有问题了

cj@vm-ubuntu:/usr/local/bin$ phantomjs --version
2.1.1

from selenium import webdriver import requests from multiprocessing.pool import Pool from lxml import etree #爬取京东商城 browser = webdriver.PhantomJS() def save(content): with open('television.doc', 'a', encoding='gbk')as f: f.writelines(content) def paser_index(url): browser.get(url) selector = etree.HTML(browser.page_source) items = selector.xpath('//li[@class="gl-item"]') for item in items: price = '商品价格/元:'+item.xpath('.//strong[@class="J_price"]//i/text()')[0] title = str(item.xpath('./div/div[3]/a/em/text()')[0]).strip() comment = '评论数:'+item.xpath('.//div[@class="p-commit p-commit-n"]//a/text()')[0] price_buy = item.xpath('.//span[@class="buy-score"]/em/text()') if price_buy: price_buy = '商品性价比:'+price_buy[0] else: price_buy = 'none' shop = item.xpath('.//div[@class="p-shop"]/span/a/text()')[0] href = 'https:' + item.xpath('.//div[@class="p-img"]/a/@href')[0] print(price + '\n', title + '\n', comment + '\n', price_buy + '\n', shop + '\n') info = [price, title, comment, price_buy, shop] save('\n'.join(info)) content = get_detail(href) detail_paser(content) def get_detail(url): #获取商品详情页 response = requests.get(url) return response.text def detail_paser(content): #解析商品详情页 details = etree.HTML(content) lis = details.xpath('//ul[@class="parameter2 p-parameter-list"]//li') for li in lis: prodrcts = li.xpath('.//text()')[0] save(prodrcts+'\n') print(prodrcts) if __name__ == '__main__': #多线程爬取 print('开始。。。。。。。。。。。。。。。。。。。。。。。。') urls = ['https://list.jd.com/list.html?cat=737,794,798&page={}'.format(str(i)) for i in range(1, 3)] pool = Pool() result = pool.map(paser_index, urls) pool.close() pool.join() 这是抓取京东商城商品信息的程序,执行过程中出现了下面的错误提示,根据错误提示分析问题原因,并修正程序代码。Traceback (most recent call last): File "D:\AIProject\爬京东商城商品信息.py", line 1, in <module> from selenium import webdriver ModuleNotFoundError: No module named 'selenium'
最新发布
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值