Update app.py
Browse files
app.py
CHANGED
|
@@ -12,21 +12,21 @@ os.makedirs(OUT, exist_ok=True)
|
|
| 12 |
headers = {'User-Agent': 'Mozilla/5.0'}
|
| 13 |
|
| 14 |
@app.get("/search")
|
| 15 |
-
def search(
|
| 16 |
-
r = requests.get(f"{BASE}/search?search={quote(
|
| 17 |
soup = BeautifulSoup(r.content, 'html.parser')
|
| 18 |
results = []
|
| 19 |
for item in soup.select('.c-tabs-item__content'):
|
| 20 |
a = item.select_one('.post-title a')
|
| 21 |
if not a: continue
|
| 22 |
href = a.get('href', '')
|
| 23 |
-
|
| 24 |
slug = href.rstrip('/').split('/')[-1]
|
| 25 |
chap = item.select_one('.chapter a')
|
| 26 |
date = item.select_one('.post-on .font-meta')
|
| 27 |
rating = item.select_one('.score')
|
| 28 |
results.append({
|
| 29 |
-
"title":
|
| 30 |
"slug": slug,
|
| 31 |
"latest": chap.get_text(strip=True) if chap else None,
|
| 32 |
"date": date.get_text(strip=True) if date else None,
|
|
|
|
| 12 |
headers = {'User-Agent': 'Mozilla/5.0'}
|
| 13 |
|
| 14 |
@app.get("/search")
|
| 15 |
+
def search(title: str):
|
| 16 |
+
r = requests.get(f"{BASE}/search?search={quote(title)}", headers=headers)
|
| 17 |
soup = BeautifulSoup(r.content, 'html.parser')
|
| 18 |
results = []
|
| 19 |
for item in soup.select('.c-tabs-item__content'):
|
| 20 |
a = item.select_one('.post-title a')
|
| 21 |
if not a: continue
|
| 22 |
href = a.get('href', '')
|
| 23 |
+
name = a.get_text(strip=True)
|
| 24 |
slug = href.rstrip('/').split('/')[-1]
|
| 25 |
chap = item.select_one('.chapter a')
|
| 26 |
date = item.select_one('.post-on .font-meta')
|
| 27 |
rating = item.select_one('.score')
|
| 28 |
results.append({
|
| 29 |
+
"title": name,
|
| 30 |
"slug": slug,
|
| 31 |
"latest": chap.get_text(strip=True) if chap else None,
|
| 32 |
"date": date.get_text(strip=True) if date else None,
|