arpy8 commited on
Commit
69d5551
·
1 Parent(s): 503d4d2

refactor: Update User-Agent header to use a unique identifier

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,9 +1,11 @@
1
- from typing import Dict, List, Any
2
  import bs4
 
3
  import requests
 
4
  from fastapi import FastAPI, HTTPException
5
  from fastapi.middleware.cors import CORSMiddleware
6
 
 
7
  app = FastAPI()
8
 
9
  app.add_middleware(
@@ -21,7 +23,8 @@ def fetch_github_page(**kwargs) -> str:
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',
 
 
1
  import bs4
2
+ import uuid
3
  import requests
4
+ from typing import Dict, List, Any
5
  from fastapi import FastAPI, HTTPException
6
  from fastapi.middleware.cors import CORSMiddleware
7
 
8
+
9
  app = FastAPI()
10
 
11
  app.add_middleware(
 
23
  params = '&'.join([f'{k}={v}' for k, v in kwargs.items()])
24
  url = 'https://github.com/topics/hacktoberfest?{}'.format(params)
25
  headers = {
26
+ # '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',
27
+ 'User-Agent': str(uuid.uuid4()),
28
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
29
  'Accept-Language': 'en-US,en;q=0.9',
30
  'Accept-Encoding': 'gzip, deflate, br',