Omar ID EL MOUMEN commited on
Commit
442a98d
·
1 Parent(s): 271cfb4

Add URL in Keyword search + fix new spec id format

Browse files
Files changed (2) hide show
  1. app.py +10 -3
  2. static/script.js +1 -0
app.py CHANGED
@@ -196,7 +196,8 @@ class SpecDocFinder:
196
  try:
197
  item = items[-1].find("a")
198
  except Exception as e:
199
- return f"Unable to find specification {doc_id} : {e}"
 
200
  a, b, c = [_ for _ in item.get_text().split("-")[-1].replace(".zip", "")]
201
  version = f"{self.chars.index(a)}.{self.chars.index(b)}.{self.chars.index(c)}"
202
  version_found = (version, item.get("href"))
@@ -221,6 +222,7 @@ async def main_menu():
221
 
222
  @app.post("/search-spec", response_model=KeywordResponse)
223
  def search_spec(request: KeywordRequest):
 
224
  start_time = time.time()
225
  response = requests.get(f'https://www.3gpp.org/dynareport?code=status-report.htm', headers={"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}, verify=False)
226
  dfs = pd.read_html(StringIO(response.text), storage_options={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}, encoding="utf-8")
@@ -263,14 +265,19 @@ def search_spec(request: KeywordRequest):
263
  continue
264
  if spec_type is not None and spec["type"] != spec_type:
265
  continue
266
-
 
 
 
 
267
  results.append({
268
  "id": str(spec["spec_num"]),
269
  "title": spec["title"],
270
  "type": "Technical Specification" if spec["type"] == "TS" else "Technical Report",
271
  "release": str(spec["vers"].split(".")[0]),
272
  "version": str(spec["vers"]),
273
- "working_group": spec["WG"]
 
274
  })
275
 
276
  if len(results) > 0:
 
196
  try:
197
  item = items[-1].find("a")
198
  except Exception as e:
199
+ print(e)
200
+ return f"Unable to find specification {doc_id}"
201
  a, b, c = [_ for _ in item.get_text().split("-")[-1].replace(".zip", "")]
202
  version = f"{self.chars.index(a)}.{self.chars.index(b)}.{self.chars.index(c)}"
203
  version_found = (version, item.get("href"))
 
222
 
223
  @app.post("/search-spec", response_model=KeywordResponse)
224
  def search_spec(request: KeywordRequest):
225
+ chars = "0123456789abcdefghijklmnopqrstuvwxyz"
226
  start_time = time.time()
227
  response = requests.get(f'https://www.3gpp.org/dynareport?code=status-report.htm', headers={"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}, verify=False)
228
  dfs = pd.read_html(StringIO(response.text), storage_options={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}, encoding="utf-8")
 
265
  continue
266
  if spec_type is not None and spec["type"] != spec_type:
267
  continue
268
+
269
+ doc_id = str(spec["spec_num"])
270
+ series = doc_id.split(".")[0]
271
+ a, b, c = str(spec["vers"]).split(".")
272
+ spec_url = f"https://www.3gpp.org/ftp/Specs/archive/{series}_series/{doc_id}/{doc_id.replace('.', '')}-{chars[int(a)]}{chars[int(b)]}{chars[int(c)]}.zip"
273
  results.append({
274
  "id": str(spec["spec_num"]),
275
  "title": spec["title"],
276
  "type": "Technical Specification" if spec["type"] == "TS" else "Technical Report",
277
  "release": str(spec["vers"].split(".")[0]),
278
  "version": str(spec["vers"]),
279
+ "working_group": spec["WG"],
280
+ "url": spec_url
281
  })
282
 
283
  if len(results) > 0:
static/script.js CHANGED
@@ -242,6 +242,7 @@ function displayKeywordResults(data) {
242
  <p>Release: ${spec.release}</p>
243
  <p>Version: ${spec.version}</p>
244
  <p>WG: ${spec.working_group}</p>
 
245
  </div>
246
  `;
247
  resultsList.appendChild(resultItem);
 
242
  <p>Release: ${spec.release}</p>
243
  <p>Version: ${spec.version}</p>
244
  <p>WG: ${spec.working_group}</p>
245
+ <p>URL: <a target="_blank" href="${spec.url}">${spec.url}</a></p>
246
  </div>
247
  `;
248
  resultsList.appendChild(resultItem);