navpan2 commited on
Commit
10912e0
·
1 Parent(s): 003e243

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -25
main.py CHANGED
@@ -1,35 +1,16 @@
1
 
2
  from fastapi import FastAPI
3
- import time
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("/selenium/")
22
- async def read_item(reqUrl,tag):
23
- driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=chrome_options)
24
- url= reqUrl
25
- driver.get(url)
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