Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -32,11 +32,15 @@ collection_url = f"https://www.loc.gov/{collection_info['path']}/search/?q={coll
|
|
32 |
st.sidebar.write(f"Selected Collection: {selected}")
|
33 |
st.sidebar.write(f"API URL: {collection_url}")
|
34 |
|
35 |
-
# Fetch data from LOC API with
|
|
|
|
|
|
|
|
|
36 |
try:
|
37 |
-
response = requests.get(collection_url)
|
38 |
response.raise_for_status() # Raise exception for 4XX/5XX responses
|
39 |
-
|
40 |
|
41 |
# Handle both possible response structures
|
42 |
if "results" in data:
|
|
|
32 |
st.sidebar.write(f"Selected Collection: {selected}")
|
33 |
st.sidebar.write(f"API URL: {collection_url}")
|
34 |
|
35 |
+
# Fetch data from LOC API with spoofed User-Agent header
|
36 |
+
headers = {
|
37 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/110.0.0.0 Safari/537.36"
|
38 |
+
}
|
39 |
+
|
40 |
try:
|
41 |
+
response = requests.get(collection_url, headers=headers)
|
42 |
response.raise_for_status() # Raise exception for 4XX/5XX responses
|
43 |
+
|
44 |
|
45 |
# Handle both possible response structures
|
46 |
if "results" in data:
|