Spaces:
Runtime error
Runtime error
added recommendations
Browse files- .gitignore +1 -0
- app.py +22 -19
- aux_files/aux_file.exii +0 -0
.gitignore
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
__pycache__/
|
| 3 |
*.py[cod]
|
| 4 |
*$py.class
|
|
|
|
| 5 |
|
| 6 |
# C extensions
|
| 7 |
*.so
|
|
|
|
| 2 |
__pycache__/
|
| 3 |
*.py[cod]
|
| 4 |
*$py.class
|
| 5 |
+
aux_files.py
|
| 6 |
|
| 7 |
# C extensions
|
| 8 |
*.so
|
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import glob
|
|
| 3 |
import json
|
| 4 |
import math
|
| 5 |
import time
|
|
|
|
| 6 |
import openai
|
| 7 |
import requests
|
| 8 |
import pandas as pd
|
|
@@ -14,25 +15,6 @@ from scrapingbee import ScrapingBeeClient
|
|
| 14 |
|
| 15 |
global scraped_folder_path, category_folder_path, log_file_path, openapikey, scrapingbeekey, excel_file
|
| 16 |
|
| 17 |
-
openapikey = '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' #'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'
|
| 18 |
-
scarpingbeekey = 'ASMNQ1219V3ONQDE64VU1VYU0YKP1RPYKEYQ61Z28QLRE52H7ORMWDTT68BJYZOPBTKDWRFB6AFKLYYR'#'ASMNQ1219V3ONQDE64VU1VYU0YKP1RPYKEYQ61Z28QLRE52H7ORMWDTT68BJYZOPBTKDWRFB6AFKLYYR'
|
| 19 |
-
|
| 20 |
-
os.environ['OPEN_API_KEY'] = openapikey
|
| 21 |
-
openai.api_key = openapikey
|
| 22 |
-
|
| 23 |
-
def send_request(google_prompt):
|
| 24 |
-
response = requests.get(
|
| 25 |
-
url="https://app.scrapingbee.com/api/v1/store/google",
|
| 26 |
-
params={
|
| 27 |
-
"api_key": scarpingbeekey,
|
| 28 |
-
"search": google_prompt,
|
| 29 |
-
"add_html": True,
|
| 30 |
-
"nb_results": 1
|
| 31 |
-
},
|
| 32 |
-
|
| 33 |
-
)
|
| 34 |
-
return response.json()
|
| 35 |
-
|
| 36 |
# definition to create folder
|
| 37 |
def create_folder(_path):
|
| 38 |
try:
|
|
@@ -239,6 +221,27 @@ def log_to_file(f, general_question, question_dictionary, useless_urls, complete
|
|
| 239 |
f.write("---------------------------------------------------------------------------------------------------------------------------------\n")
|
| 240 |
print("----------------------------------------------------------------------\n")
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
def get_json_dict(df, web_list, progress, name):
|
| 243 |
filename="/" + name + "_log.txt"
|
| 244 |
with open(log_file_path+filename, 'w+', encoding='utf-8') as f:
|
|
|
|
| 3 |
import json
|
| 4 |
import math
|
| 5 |
import time
|
| 6 |
+
import pickle
|
| 7 |
import openai
|
| 8 |
import requests
|
| 9 |
import pandas as pd
|
|
|
|
| 15 |
|
| 16 |
global scraped_folder_path, category_folder_path, log_file_path, openapikey, scrapingbeekey, excel_file
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# definition to create folder
|
| 19 |
def create_folder(_path):
|
| 20 |
try:
|
|
|
|
| 221 |
f.write("---------------------------------------------------------------------------------------------------------------------------------\n")
|
| 222 |
print("----------------------------------------------------------------------\n")
|
| 223 |
|
| 224 |
+
constants = pickle.load(open('aux_files/aux_file.exii', 'rb'))
|
| 225 |
+
|
| 226 |
+
openapikey = constants['openapi_key']
|
| 227 |
+
scarpingbeekey = constants['scrapingbee_key']
|
| 228 |
+
|
| 229 |
+
os.environ['OPEN_API_KEY'] = openapikey
|
| 230 |
+
openai.api_key = openapikey
|
| 231 |
+
|
| 232 |
+
def send_request(google_prompt):
|
| 233 |
+
response = requests.get(
|
| 234 |
+
url="https://app.scrapingbee.com/api/v1/store/google",
|
| 235 |
+
params={
|
| 236 |
+
"api_key": scarpingbeekey,
|
| 237 |
+
"search": google_prompt,
|
| 238 |
+
"add_html": True,
|
| 239 |
+
"nb_results": 1
|
| 240 |
+
},
|
| 241 |
+
|
| 242 |
+
)
|
| 243 |
+
return response.json()
|
| 244 |
+
|
| 245 |
def get_json_dict(df, web_list, progress, name):
|
| 246 |
filename="/" + name + "_log.txt"
|
| 247 |
with open(log_file_path+filename, 'w+', encoding='utf-8') as f:
|
aux_files/aux_file.exii
ADDED
|
Binary file (185 Bytes). View file
|
|
|