Spaces:
Sleeping
Sleeping
AngelaKkkkkkkkk
commited on
Commit
•
1dfc2a4
1
Parent(s):
1c57ff6
Update app.py
Browse files
app.py
CHANGED
@@ -2,11 +2,15 @@ import gradio as gr
|
|
2 |
import requests
|
3 |
from bs4 import BeautifulSoup
|
4 |
|
5 |
-
# Function to scrape a specific website
|
6 |
def scrape_website(url):
|
7 |
try:
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Check if the response was successful
|
12 |
if response.status_code == 200:
|
|
|
2 |
import requests
|
3 |
from bs4 import BeautifulSoup
|
4 |
|
5 |
+
# Function to scrape a specific website with a User-Agent header
|
6 |
def scrape_website(url):
|
7 |
try:
|
8 |
+
headers = {
|
9 |
+
"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"
|
10 |
+
}
|
11 |
+
|
12 |
+
# Send a request to the website with the headers
|
13 |
+
response = requests.get(url, headers=headers, allow_redirects=True)
|
14 |
|
15 |
# Check if the response was successful
|
16 |
if response.status_code == 200:
|