【发布时间】:2019-10-01 04:06:40
【问题描述】:
我正在尝试使用 selenium 和 BeautifulSoup 抓取 js 呈现的网站。该代码工作正常,但我需要在没有任何 chrome 的服务器上运行它。我应该在没有 GUI 的情况下对代码进行哪些更改?
下面是当前代码:
from bs4 import BeautifulSoup
import selenium.webdriver as webdriver
import json
from selenium.webdriver.common.keys import Keys
url = 'https://www.bigbasket.com/pc/fruits-vegetables/fresh-vegetables/?nc=nb'
chromepath = "/Users/Nitin/Desktop/Milkbasket/Scraping/chromedriver"
driver = driver = webdriver.Chrome(chromepath)
driver.get(url)
#rest of code for fetching prices
【问题讨论】:
-
服务器有firefox mozilla吗?
-
no.. 服务器不支持任何 gui
-
也许可以解决您的问题,链接:duo.com/decipher/driving-headless-chrome-with-python
-
这不起作用
-
你能举几个例子来说明你的预期输出吗?
标签: python selenium web-scraping beautifulsoup phantomjs