[英]Selenium,Django, On Ubuntu 20.04 digital ocean VPD
我創建了 web 刮刀並將其與 Django 集成。 一切正常。 現在我想在 VPS 上使用 webscraper 托管 Django 應用程序,以便他可以在任何地方訪問它。 我也在使用gunicorn
和nginx
。 I tried that Django app with webdriver.remote()
using seleniumgrid
its working fine on my normal windows environment, but as soon as I put it on my ubuntu vps it works only in half of cases - like all my Django stuff is accessible and operational ,但是當我的 django 調用刮板時,它只是通過而沒有任何響應。
def chromedriver_setup():
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
# proxies = proxies = [{"_id":"62cd1bf852694154bb14f2e7","ip":"178.32.148.251","anonymityLevel":"elite","asn":"AS16276","city":"Gravelines","country":"FR","created_at":"2022-07-12T07:00:08.515Z","google":True,"isp":"OVH SAS","lastChecked":1657848951,"latency":5.13,"org":"MICHOTTE Maxime","port":"8080","protocols":["socks4"], "speed":37,"updated_at":"2022-07-15T01:35:51.569Z" },{"_id":"60d613cdce5b3bb0e932edce","ip":"64.227.62.123","port":"80","anonymityLevel":"elite","asn":"AS14061","city":"Santa Clara","country":"US","created_at":"2021-06-25T17:35:09.953Z","google":True, "isp":"DigitalOcean, LLC","lastChecked":1657847332,"latency":153,"org":"DigitalOcean, LLC","protocols":["http"], "speed":306,"updated_at":"2022-07-15T01:08:52.862Z" ,"upTime":99.98473981382573,"upTimeSuccessCount":6552,"upTimeTryCount":6553}]
# random_ip = random.choice(proxies)
# PROXY = str(random_ip["ip"] + ":" + random_ip["port"])
option = webdriver.ChromeOptions()
option.add_argument("--headless")
option.add_argument(f'user-agent={user_agent}')
option.add_argument("--window-size=1920,1080")
option.add_argument("--start-maximized")
option.add_argument("--disable-gpu")
# # option.add_argument('--proxy-server=%s' % PROXY)
option.add_experimental_option("excludeSwitches", ["enable-automation"])
option.add_experimental_option('useAutomationExtension', False)
option.add_argument("--disable-blink-features=AutomationControlled")
option.add_experimental_option("detach", True)
print("chrome driver setup passed")
driver = webdriver.Remote(
command_executor='192.168.72.1:4444',
desired_capabilities = DesiredCapabilities.CHROME,
options=option,
)
return driver
有什么辦法可以解決這個問題或測試我..?
根據提供的信息,我真的想不出任何會導致問題的東西或您應該尋找的任何東西。
但是,考慮到您的刮板在 windows 環境中運行良好這一事實,我可以建議的是找到一個 windows 服務器而不是 Linux 機器,然后看看它是如何運行的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.