File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -624,3 +624,21 @@ def merge_two_level_dicts(dict1, dict2):
624624 "highest_controversy" }
625625}
626626EQUITY_SCREENER_FIELDS = merge_two_level_dicts (EQUITY_SCREENER_FIELDS , COMMON_SCREENER_FIELDS )
627+
628+ USER_AGENTS = [
629+ # Chrome
630+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" ,
631+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" ,
632+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" ,
633+
634+ # Firefox
635+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0" ,
636+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 14.7; rv:135.0) Gecko/20100101 Firefox/135.0" ,
637+ "Mozilla/5.0 (X11; Linux i686; rv:135.0) Gecko/20100101 Firefox/135.0" ,
638+
639+ # Safari
640+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15" ,
641+
642+ # Edge
643+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/131.0.2903.86"
644+ ]
Original file line number Diff line number Diff line change 11import functools
2+ import random
23from functools import lru_cache
34
45import requests as requests
1011from . import utils , cache
1112import threading
1213
14+ from .const import USER_AGENTS
1315from .exceptions import YFRateLimitError
1416
1517cache_maxsize = 64
@@ -59,7 +61,8 @@ class YfData(metaclass=SingletonMeta):
5961 Singleton means one session one cookie shared by all threads.
6062 """
6163 user_agent_headers = {
62- 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36' }
64+ 'User-Agent' : random .choice (USER_AGENTS )
65+ }
6366
6467 def __init__ (self , session = None ):
6568 self ._crumb = None
You can’t perform that action at this time.
0 commit comments