Spaces:
Runtime error
Runtime error
add headers
Browse files
app.py
CHANGED
|
@@ -20,7 +20,20 @@ def fetch_github_page(**kwargs) -> str:
|
|
| 20 |
try:
|
| 21 |
params = '&'.join([f'{k}={v}' for k, v in kwargs.items()])
|
| 22 |
url = 'https://github.com/topics/hacktoberfest?{}'.format(params)
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
response.raise_for_status()
|
| 25 |
|
| 26 |
return response.text
|
|
|
|
| 20 |
try:
|
| 21 |
params = '&'.join([f'{k}={v}' for k, v in kwargs.items()])
|
| 22 |
url = 'https://github.com/topics/hacktoberfest?{}'.format(params)
|
| 23 |
+
headers = {
|
| 24 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
|
| 25 |
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
| 26 |
+
'Accept-Language': 'en-US,en;q=0.9',
|
| 27 |
+
'Accept-Encoding': 'gzip, deflate, br',
|
| 28 |
+
'Connection': 'keep-alive',
|
| 29 |
+
'Upgrade-Insecure-Requests': '1',
|
| 30 |
+
'Sec-Fetch-Dest': 'document',
|
| 31 |
+
'Sec-Fetch-Mode': 'navigate',
|
| 32 |
+
'Sec-Fetch-Site': 'none',
|
| 33 |
+
'Sec-Fetch-User': '?1',
|
| 34 |
+
'Cache-Control': 'max-age=0',
|
| 35 |
+
}
|
| 36 |
+
response = requests.get(url, headers)
|
| 37 |
response.raise_for_status()
|
| 38 |
|
| 39 |
return response.text
|