Update web_scraper.py
Browse files- web_scraper.py +8 -0
web_scraper.py
CHANGED
@@ -10,9 +10,17 @@ import base64
|
|
10 |
from io import BytesIO
|
11 |
from googlesearch import search
|
12 |
import json
|
|
|
13 |
|
14 |
app = Flask(__name__)
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def search_images(query, num_images=5):
|
17 |
# Headers to mimic a browser request
|
18 |
headers = {
|
|
|
10 |
from io import BytesIO
|
11 |
from googlesearch import search
|
12 |
import json
|
13 |
+
import logging
|
14 |
|
15 |
app = Flask(__name__)
|
16 |
|
17 |
+
logger = logging.getLogger()
|
18 |
+
queue_handler = QueueHandler()
|
19 |
+
queue_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
|
20 |
+
queue_handler.addFilter(SocketWarningFilter()) # Add the filter to the handler
|
21 |
+
logger.addHandler(queue_handler)
|
22 |
+
logger.setLevel(logging.INFO)
|
23 |
+
|
24 |
def search_images(query, num_images=5):
|
25 |
# Headers to mimic a browser request
|
26 |
headers = {
|