*****.request import TrendReq
pytrends = TrendReq(hl='ja-JP', tz=-540, timeout=(10,25), proxies=['https://34.203.233.13:80',], retries=2, backoff_factor=0.1)
trend = pytrends.trending_searches(pn='japan')
print(trend)
### エラーコード ユーザー名は*****で伏せています File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 159, in _new_conn conn = connection.create_connection( File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection raise err File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection sock.connect(sa) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 667, in urlopen self._prepare_proxy(conn) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 932, in _prepare_proxy conn.connect() File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 309, in connect conn = self._new_conn() File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 164, in _new_conn raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x000002079C9FE7F0>, 'Connection to 34.203.233.13 timed out. (connect timeout=10)') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 439, in send resp = conn.urlopen( File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen retries = retries.increment( File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 439, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='trends.google.com', port=443): Max retries exceeded with url: /?geo=JP (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000002079C9FE7F0>, 'Connection to 34.203.233.13 timed out. (connect timeout=10)')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:/Users/*****/tech_club Gtrend/Google trend/test.py", line 2, in <module> pytrends = TrendReq(hl='ja-JP', tz=-540, timeout=(10,25), proxies=['https://34.203.233.13:80',], retries=2, backoff_factor=0.1) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\pytrends\request.py", line 58, in __init__ self.cookies = self.GetGoogleCookie() File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\pytrends\request.py", line 77, in GetGoogleCookie return dict(filter(lambda i: i[0] == 'NID', requests.get( File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 76, in get File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 530, in request resp = self.send(prep, **send_kwargs) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 643, in send r = adapter.send(request, **kwargs) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 504, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='trends.google.com', port=443): Max retries exceeded with url: /?geo=JP (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000002079C9FE7F0>, 'Connection to 34.203.233.13 timed out. (connect timeout=10)')) PS C:\Users*****\tech_club Gtrend> & C:/Users/*****/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/*****/tech_club Gtrend/Google trend/test.py" Traceback (most recent call last): File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 159, in _new_conn conn = connection.create_connection( File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection raise err File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection sock.connect(sa) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 667, in urlopen self._prepare_proxy(conn) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 932, in _prepare_proxy conn.connect() File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 309, in connect conn = self._new_conn() File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 164, in _new_conn raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x0000021B2DA8E7F0>, 'Connection to 34.203.233.13 timed out. (connect timeout=10)') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 439, in send resp = conn.urlopen( File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen retries = retries.increment( File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 439, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='trends.google.com', port=443): Max retries exceeded with url: /?geo=JP (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000021B2DA8E7F0>, 'Connection to 34.203.233.13 timed out. (connect timeout=10)')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:/Users/*****/tech_club Gtrend/Google trend/test.py", line 2, in <module> pytrends = TrendReq(hl='ja-JP', tz=-540, timeout=(10,25), proxies=['https://34.203.233.13:80',], retries=2, backoff_factor=0.1) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\pytrends\request.py", line 58, in __init__ self.cookies = self.GetGoogleCookie() File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\pytrends\request.py", line 77, in GetGoogleCookie return dict(filter(lambda i: i[0] == 'NID', requests.get( File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 76, in get return request('get', url, params=params, **kwargs) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 530, in request resp = self.send(prep, **send_kwargs) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 643, in send r = adapter.send(request, **kwargs) File "C:\Users*****\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 504, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='trends.google.com', port=443): Max retries exceeded with url: /?geo=JP (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000021B2DA8E7F0>, 'Connection to 34.203.233.13 timed out. (connect timeout=10)')) ### 実行環境 Windows10 Pro 2004(OSビルド 19041.41) Python 3.8.3 pytrends 4.7.3 Visual Studio Code 1.47.3
あなたの回答
tips
プレビュー