Spaces:
Runtime error
Runtime error
Commit ·
fe89926
1
Parent(s): 0eacdd5
afa
Browse files- Dockerfile +40 -50
- __pycache__/app.cpython-311.pyc +0 -0
- app.py +222 -209
Dockerfile
CHANGED
|
@@ -1,61 +1,51 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
# RUN apt-get update && apt-get install -y wget unzip && \
|
| 26 |
# wget https://dl.google.com/Linux/direct/google-chrome-stable_current_amd64.deb && \
|
| 27 |
# apt install -y ./google-chrome-stable_current_amd64.deb && \
|
| 28 |
# rm google-chrome-stable_current_amd64.deb && \
|
| 29 |
# apt-get clean
|
| 30 |
-
# RUN useradd -m -u 1000 user
|
| 31 |
-
# USER user
|
| 32 |
-
# ENV HOME=/home/user \
|
| 33 |
-
# PATH=/home/user/.local/bin:$PATH
|
| 34 |
-
|
| 35 |
-
# WORKDIR $HOME/app
|
| 36 |
-
# # WORKDIR /app
|
| 37 |
-
|
| 38 |
-
# COPY --chown=user . $HOME/app
|
| 39 |
-
# # COPY . /app
|
| 40 |
-
# # Install Python dependencies
|
| 41 |
-
# RUN pip install --no-cache-dir -r requirements.txt
|
| 42 |
-
|
| 43 |
-
# # Run the Selenium script
|
| 44 |
-
# # CMD ["gunicorn", "-b", "0.0.0.0:7860","app:app"]
|
| 45 |
-
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 46 |
-
ARG PORT=443
|
| 47 |
-
FROM cypress/browsers:latest
|
| 48 |
-
|
| 49 |
-
RUN apt-get install python3 -y
|
| 50 |
-
|
| 51 |
-
RUN echo $(python3 -m site --user-base)
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
|
|
|
| 58 |
|
| 59 |
-
COPY
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the official Python image as the base image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Install dependencies for Selenium and Chrome
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
wget \
|
| 7 |
+
unzip \
|
| 8 |
+
curl \
|
| 9 |
+
gnupg \
|
| 10 |
+
libnss3 \
|
| 11 |
+
libgconf-2-4 \
|
| 12 |
+
libxi6 \
|
| 13 |
+
libxcursor1 \
|
| 14 |
+
libxrandr2 \
|
| 15 |
+
libxss1 \
|
| 16 |
+
libxtst6 \
|
| 17 |
+
fonts-liberation \
|
| 18 |
+
xdg-utils \
|
| 19 |
+
libatk-bridge2.0-0 \
|
| 20 |
+
libgtk-3-0 \
|
| 21 |
+
--no-install-recommends && \
|
| 22 |
+
apt-get clean && \
|
| 23 |
+
rm -rf /var/lib/apt/lists/*
|
| 24 |
|
| 25 |
# RUN apt-get update && apt-get install -y wget unzip && \
|
| 26 |
# wget https://dl.google.com/Linux/direct/google-chrome-stable_current_amd64.deb && \
|
| 27 |
# apt install -y ./google-chrome-stable_current_amd64.deb && \
|
| 28 |
# rm google-chrome-stable_current_amd64.deb && \
|
| 29 |
# apt-get clean
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
# Update the package list and install wget, unzip, and Firefox
|
| 32 |
+
RUN apt-get update && apt-get install -y wget unzip \
|
| 33 |
+
&& apt-get install -y firefox-esr \
|
| 34 |
+
&& apt-get clean
|
| 35 |
|
| 36 |
+
RUN useradd -m -u 1000 user
|
| 37 |
+
USER user
|
| 38 |
+
ENV HOME=/home/user \
|
| 39 |
+
PATH=/home/user/.local/bin:$PATH
|
| 40 |
|
| 41 |
+
WORKDIR $HOME/app
|
| 42 |
+
# WORKDIR /app
|
| 43 |
|
| 44 |
+
COPY --chown=user . $HOME/app
|
| 45 |
+
# COPY . /app
|
| 46 |
+
# Install Python dependencies
|
| 47 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 48 |
|
| 49 |
+
# Run the Selenium script
|
| 50 |
+
# CMD ["gunicorn", "-b", "0.0.0.0:7860","app:app"]
|
| 51 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
__pycache__/app.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
|
|
|
app.py
CHANGED
|
@@ -1,174 +1,175 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
#
|
| 37 |
-
#
|
| 38 |
-
#
|
| 39 |
-
|
| 40 |
-
#
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
#
|
| 46 |
-
#
|
| 47 |
-
#
|
| 48 |
-
#
|
| 49 |
-
#
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
#
|
| 56 |
-
#
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
#
|
| 60 |
-
|
| 61 |
-
#
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
#
|
| 68 |
-
#
|
| 69 |
-
#
|
| 70 |
-
#
|
| 71 |
-
# browser_option.add_argument(
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
#
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
#
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
#
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
#
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
# @app.get("/get-reddit/")
|
| 173 |
# async def getReddit(url: str):
|
| 174 |
# """
|
|
@@ -199,43 +200,55 @@
|
|
| 199 |
# except Exception as e:
|
| 200 |
# raise HTTPException(status_code=500, detail=str(e))
|
| 201 |
|
| 202 |
-
#
|
| 203 |
-
#
|
| 204 |
-
#
|
| 205 |
-
#
|
| 206 |
-
|
| 207 |
-
from selenium import webdriver
|
| 208 |
-
from flask import Flask, request
|
| 209 |
-
from selenium.webdriver.chrome.service import Service
|
| 210 |
-
from webdriver_manager.chrome import ChromeDriverManager
|
| 211 |
-
from selenium.webdriver.common.by import By
|
| 212 |
-
|
| 213 |
-
app = Flask(__name__)
|
| 214 |
-
|
| 215 |
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import random
|
| 3 |
+
import time
|
| 4 |
+
import pandas as pd
|
| 5 |
+
from fastapi import FastAPI, HTTPException
|
| 6 |
+
from selenium import webdriver
|
| 7 |
+
from selenium.webdriver.firefox.service import Service
|
| 8 |
+
from selenium.webdriver.common.action_chains import ActionChains
|
| 9 |
+
from selenium.webdriver.firefox.options import Options
|
| 10 |
+
from webdriver_manager.firefox import GeckoDriverManager
|
| 11 |
+
from webdriver_manager.core.driver_cache import DriverCacheManager
|
| 12 |
+
from selenium.webdriver.common.by import By
|
| 13 |
+
from fake_headers import Headers
|
| 14 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 15 |
+
import logging
|
| 16 |
+
from selenium_driverless import webdriver as webdriverless
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Initialize FastAPI
|
| 20 |
+
app = FastAPI(
|
| 21 |
+
debug=True,
|
| 22 |
+
title="NextAnalytics Server",
|
| 23 |
+
consumes=["application/x-www-form-urlencoded", "multipart/form-data"],
|
| 24 |
+
docs_url='/swagger'
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# Configure CORS
|
| 28 |
+
app.add_middleware(
|
| 29 |
+
CORSMiddleware,
|
| 30 |
+
allow_origins=["*"],
|
| 31 |
+
allow_credentials=True,
|
| 32 |
+
allow_methods=["*"],
|
| 33 |
+
allow_headers=["*"],
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
# Setup ChromeDriver and Selenium
|
| 37 |
+
# custom_wdm_cache = os.path.join(os.getcwd(), 'custom_wdm_cache')
|
| 38 |
+
# os.environ['WDM_LOCAL'] = custom_wdm_cache
|
| 39 |
+
|
| 40 |
+
# Setup logging
|
| 41 |
+
logging.basicConfig(level=logging.INFO)
|
| 42 |
+
|
| 43 |
+
def setup_chromedriver():
|
| 44 |
+
logging.info("Setting up ChromeDriver...")
|
| 45 |
+
# custom_wdm_cache = os.path.join(os.getcwd(), 'custom_wdm_cache')
|
| 46 |
+
# os.environ['WDM_LOCAL'] = custom_wdm_cache
|
| 47 |
+
# cache_manager = DriverCacheManager(custom_wdm_cache)
|
| 48 |
+
# os.chmod(custom_wdm_cache, 0o755) # Ensure proper permissions
|
| 49 |
+
# path = ChromeDriverManager(cache_manager=cache_manager).install()
|
| 50 |
+
path = GeckoDriverManager().install()
|
| 51 |
+
os.chmod(path, 0o755) # Ensure ChromeDriver is executable
|
| 52 |
+
logging.info(f"ChromeDriver path: {path}")
|
| 53 |
+
return path
|
| 54 |
+
|
| 55 |
+
# Setup headless Chrome options
|
| 56 |
+
# Define a custom user agent
|
| 57 |
+
my_user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0"
|
| 58 |
+
|
| 59 |
+
# my_user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
|
| 60 |
+
|
| 61 |
+
# proxy = None
|
| 62 |
+
browser_option = Options()
|
| 63 |
+
browser_option.add_argument("--headless") # Running in headless mode (no GUI)
|
| 64 |
+
browser_option.add_argument("--no-sandbox")
|
| 65 |
+
browser_option.add_argument("--disable-dev-shm-usage")
|
| 66 |
+
browser_option.add_argument("--ignore-certificate-errors")
|
| 67 |
+
# browser_option.binary_location = r'C:\Users\HP\.cache\selenium\firefox\win64\133.0\firefox.exe'
|
| 68 |
+
# browser_option.add_argument("--disable-gpu")
|
| 69 |
+
# browser_option.add_argument("--log-level=3")
|
| 70 |
+
# browser_option.add_argument("--disable-notifications")
|
| 71 |
+
# browser_option.add_argument("--disable-popup-blocking")
|
| 72 |
+
browser_option.add_argument(f"--user-agent={my_user_agent}")
|
| 73 |
+
|
| 74 |
+
# if proxy:
|
| 75 |
+
# browser_option.add_argument(f"--proxy-server={proxy}")
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
# Setup WebDriver
|
| 79 |
+
driver_path = setup_chromedriver()
|
| 80 |
+
service = Service(executable_path=driver_path)
|
| 81 |
+
driver = webdriver.Firefox(service=service, options=browser_option)
|
| 82 |
+
# actions = ActionChains(driver)
|
| 83 |
+
|
| 84 |
+
def getSearchPostData(search_keyword, index, name="", forCompetitorAnalysis=False):
|
| 85 |
+
# Navigate to the search results page
|
| 86 |
+
url = f'https://www.reddit.com/search/?q={search_keyword}'
|
| 87 |
+
driver.get(url)
|
| 88 |
+
time.sleep(3) # Consider using WebDriverWait instead of sleep for better reliability
|
| 89 |
+
logging.info("Navigated to search page.")
|
| 90 |
+
|
| 91 |
+
posts_data = []
|
| 92 |
+
list_length = 0 # posts count
|
| 93 |
+
try:
|
| 94 |
+
if forCompetitorAnalysis:
|
| 95 |
+
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
|
| 96 |
+
time.sleep(5)
|
| 97 |
+
post_cards = driver.find_elements(By.CSS_SELECTOR, 'a[data-testid="post-title-text"]')
|
| 98 |
+
post_cards_1 = driver.find_elements(By.CSS_SELECTOR, 'div[data-testid="search-counter-row"]')
|
| 99 |
+
post_cards_2 = driver.find_elements(By.CSS_SELECTOR, 'faceplate-timeago')
|
| 100 |
+
logging.info(f"Found {len(post_cards)} post cards.")
|
| 101 |
+
|
| 102 |
+
idx = list_length
|
| 103 |
+
for card in post_cards_1:
|
| 104 |
+
try:
|
| 105 |
+
votes_count = card.find_element(By.XPATH, './/faceplate-number').text
|
| 106 |
+
comments_count = card.find_element(By.XPATH,
|
| 107 |
+
'.//span[contains(text(), "comment") or contains(text(), "comments")]/preceding-sibling::faceplate-number'
|
| 108 |
+
).text
|
| 109 |
+
posts_data.append({
|
| 110 |
+
"index": idx,
|
| 111 |
+
"comment_count": comments_count,
|
| 112 |
+
"votes_count": votes_count
|
| 113 |
+
})
|
| 114 |
+
idx += 1
|
| 115 |
+
except Exception as e:
|
| 116 |
+
logging.error(f"Error processing post_card_1: {e}")
|
| 117 |
+
|
| 118 |
+
idx = list_length
|
| 119 |
+
for card in post_cards:
|
| 120 |
+
try:
|
| 121 |
+
url = card.get_attribute("href")
|
| 122 |
+
title = card.text
|
| 123 |
+
posts_data[idx]["title"] = title
|
| 124 |
+
posts_data[idx]["url"] = url
|
| 125 |
+
idx += 1
|
| 126 |
+
except Exception as e:
|
| 127 |
+
logging.error(f"Error processing post_cards: {e}")
|
| 128 |
|
| 129 |
+
idx = list_length
|
| 130 |
+
for card in post_cards_2:
|
| 131 |
+
try:
|
| 132 |
+
time_element = card.find_element(By.XPATH, './time')
|
| 133 |
+
post_time = time_element.get_attribute('datetime')
|
| 134 |
+
posts_data[idx]["time"] = post_time
|
| 135 |
+
idx += 1
|
| 136 |
+
except Exception as e:
|
| 137 |
+
logging.error(f"Error processing post_cards_2: {e}")
|
| 138 |
+
except Exception as e:
|
| 139 |
+
logging.error(f"Error in scrolling or extracting data: {e}")
|
| 140 |
+
|
| 141 |
+
df = pd.DataFrame(posts_data)
|
| 142 |
+
df.to_csv(f'posts_data_{index}.csv', index=False)
|
| 143 |
+
logging.info(f"Data saved to posts_data_{index}.csv")
|
| 144 |
+
return df
|
| 145 |
+
|
| 146 |
+
def get_webpage_title(url: str) -> str:
|
| 147 |
+
try:
|
| 148 |
+
getSearchPostData(search_keyword="migraine", index=0)
|
| 149 |
+
url="https://www.reddit.com"
|
| 150 |
+
driver.get(url)
|
| 151 |
+
title = driver.title
|
| 152 |
+
logging.info(f"Page title: {title}")
|
| 153 |
+
return title
|
| 154 |
+
except Exception as e:
|
| 155 |
+
logging.error(f"Error fetching webpage title: {e}")
|
| 156 |
+
return str(e)
|
| 157 |
+
|
| 158 |
+
@app.get("/")
|
| 159 |
+
async def home():
|
| 160 |
+
return {"message": "Hello"}
|
| 161 |
+
|
| 162 |
+
@app.get("/get-title/")
|
| 163 |
+
async def fetch_title(url: str):
|
| 164 |
+
"""
|
| 165 |
+
Fetch the title of a webpage by URL.
|
| 166 |
+
Example: /get-title/?url=https://www.reddit.com
|
| 167 |
+
"""
|
| 168 |
+
try:
|
| 169 |
+
title = get_webpage_title(url)
|
| 170 |
+
return {"url": url, "title": title}
|
| 171 |
+
except Exception as e:
|
| 172 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 173 |
# @app.get("/get-reddit/")
|
| 174 |
# async def getReddit(url: str):
|
| 175 |
# """
|
|
|
|
| 200 |
# except Exception as e:
|
| 201 |
# raise HTTPException(status_code=500, detail=str(e))
|
| 202 |
|
| 203 |
+
# Run the app
|
| 204 |
+
# if __name__ == "__main__":
|
| 205 |
+
# import uvicorn
|
| 206 |
+
# uvicorn.run(app, host="127.0.0.1", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
+
# from selenium import webdriver
|
| 209 |
+
# from flask import Flask, request
|
| 210 |
+
# from selenium.webdriver.chrome.service import Service
|
| 211 |
+
# from webdriver_manager.chrome import ChromeDriverManager
|
| 212 |
+
# from selenium.webdriver.common.by import By
|
| 213 |
+
# from selenium.webdriver.common.proxy import Proxy, ProxyType
|
| 214 |
+
# app = Flask(__name__)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
# def download_selenium():
|
| 218 |
+
# prox = Proxy()
|
| 219 |
+
# prox.proxy_type = ProxyType.MANUAL
|
| 220 |
+
# prox.http_proxy = "ip_addr:port"
|
| 221 |
+
# prox.socks_proxy = "ip_addr:port"
|
| 222 |
+
# prox.ssl_proxy = "ip_addr:port"
|
| 223 |
+
# chrome_options = webdriver.ChromeOptions()
|
| 224 |
+
# driver_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
|
| 225 |
+
# capabilities = webdriver.DesiredCapabilities.CHROME
|
| 226 |
+
# prox.to_capabilities(capabilities)
|
| 227 |
+
# chrome_options.add_argument("--headless=new")
|
| 228 |
+
# # chrome_options.add_argument(f"--proxy-server={proxy}")
|
| 229 |
+
# chrome_options.add_argument("--no-sandbox")
|
| 230 |
+
# chrome_options.add_argument("--disable-dev-shm-usage")
|
| 231 |
+
# # chrome_options.add_argument("--ignore-certificate-errors")
|
| 232 |
+
# # chrome_options.add_argument("--disable-gpu")
|
| 233 |
+
# # chrome_options.add_argument("--log-level=3")
|
| 234 |
+
# # chrome_options.add_argument("--disable-notifications")
|
| 235 |
+
# # chrome_options.add_argument("--disable-popup-blocking")
|
| 236 |
+
# prefs = {"profile.managed_default_content_settings.images": 2}
|
| 237 |
+
# # chrome_options.add_experimental_option("prefs", prefs)
|
| 238 |
+
# chrome_options.add_argument(f"--user-agent={driver_agent}")
|
| 239 |
+
# driver = webdriver.Chrome(service=Service(ChromeDriverManager().install(),desired_capabilities=capabilities), options=chrome_options)
|
| 240 |
+
# driver.get("https://reddit.com")
|
| 241 |
+
# title = driver.title
|
| 242 |
+
# # language = driver.find_element(By.XPATH, "//div[@id='SIvCob']").text
|
| 243 |
+
# data = {'Page Title': title}
|
| 244 |
+
# return data
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
# @app.route('/', methods = ['GET','POST'])
|
| 248 |
+
# def home():
|
| 249 |
+
# if (request.method == 'GET'):
|
| 250 |
+
# return download_selenium()
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
# if __name__ == "__main__":
|
| 254 |
+
# app.run(debug=True, port=3000)
|