Update main.py
Browse files
main.py
CHANGED
@@ -1,35 +1,16 @@
|
|
1 |
|
2 |
from fastapi import FastAPI
|
3 |
-
import
|
4 |
-
from bs4 import BeautifulSoup
|
5 |
-
from selenium import webdriver
|
6 |
-
from selenium.webdriver.chrome.service import Service
|
7 |
-
from selenium.webdriver.chrome.options import Options
|
8 |
-
from webdriver_manager.chrome import ChromeDriverManager
|
9 |
-
chrome_options = Options()
|
10 |
-
chrome_options.add_argument('--no-sandbox')
|
11 |
-
chrome_options.add_argument('--headless')
|
12 |
-
chrome_options.add_argument('--disable-gpu')
|
13 |
-
chrome_options.add_argument('--disable-dev-shm-usage')
|
14 |
|
15 |
app = FastAPI()
|
16 |
-
favicon_path='https://www.iconarchive.com/download/i49313/martin-berube/sport/Soccer.ico'
|
17 |
|
18 |
@app.get("/")
|
19 |
def read_root():
|
20 |
return {"Hello": "World"}
|
21 |
-
@app.get("/
|
22 |
-
async def read_item(reqUrl
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
time.sleep(3)
|
27 |
-
soup = BeautifulSoup(driver.page_source,'lxml')
|
28 |
-
headings = soup.find_all( name= tag)
|
29 |
-
a=[]
|
30 |
-
for heading in headings:
|
31 |
-
a.append(heading.getText())
|
32 |
-
driver.quit()
|
33 |
-
return {"Hello": a}
|
34 |
|
35 |
|
|
|
1 |
|
2 |
from fastapi import FastAPI
|
3 |
+
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
app = FastAPI()
|
|
|
6 |
|
7 |
@app.get("/")
|
8 |
def read_root():
|
9 |
return {"Hello": "World"}
|
10 |
+
@app.get("/request/")
|
11 |
+
async def read_item(reqUrl):
|
12 |
+
response=request.get(reqUrl)
|
13 |
+
a=response.text
|
14 |
+
return {"Response": a}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
|