From c775e3cf3df904263aba68feaf31e5b7650ddf60 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Fri, 10 Nov 2023 02:39:25 +0100 Subject: [PATCH] Add Python syntax highlighting to `README.md` Can easily verify this commit thanks to: ```bash git diff -w ``` --- README.md | 69 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f2315d75..0080c72a 100644 --- a/README.md +++ b/README.md @@ -50,16 +50,19 @@ Only good until Google changes their backend again :-P. When that happens feel f ### Connect to Google - from pytrends.request import TrendReq +```python +from pytrends.request import TrendReq - pytrends = TrendReq(hl='en-US', tz=360) +pytrends = TrendReq(hl='en-US', tz=360) +``` or if you want to use proxies as you are blocked due to Google rate limit: +```python +from pytrends.request import TrendReq - from pytrends.request import TrendReq - - pytrends = TrendReq(hl='en-US', tz=360, timeout=(10,25), proxies=['https://34.203.233.13:80',], retries=2, backoff_factor=0.1, requests_args={'verify':False}) +pytrends = TrendReq(hl='en-US', tz=360, timeout=(10,25), proxies=['https://34.203.233.13:80',], retries=2, backoff_factor=0.1, requests_args={'verify':False}) +``` * `timeout(connect, read)` - See explantation on this on [requests docs](https://requests.readthedocs.io/en/master/user/advanced/#timeouts) @@ -87,8 +90,10 @@ Note: the parameter `hl` specifies host language for accessing Google Trends. Note: only https proxies will work, and you need to add the port number after the proxy ip address ### Build Payload - kw_list = ["Blockchain"] - pytrends.build_payload(kw_list, cat=0, timeframe='today 5-y', geo='', gprop='') +```python +kw_list = ["Blockchain"] +pytrends.build_payload(kw_list, cat=0, timeframe='today 5-y', geo='', gprop='') +``` Parameters @@ -203,7 +208,9 @@ Many API methods use the following: ### Interest Over Time - pytrends.interest_over_time() +```python +pytrends.interest_over_time() +``` Returns pandas.Dataframe @@ -211,8 +218,10 @@ Returns pandas.Dataframe ### Multirange Interest Over Time - pytrends.build_payload(kw_list=['pizza', 'bagel'], timeframe=['2022-09-04 2022-09-10', '2022-09-18 2022-09-24'])) - pytrends.multirange_interest_over_time() +```python +pytrends.build_payload(kw_list=['pizza', 'bagel'], timeframe=['2022-09-04 2022-09-10', '2022-09-18 2022-09-24'])) +pytrends.multirange_interest_over_time() +``` Returns pandas.Dataframe. It includes the average in the first row. @@ -220,7 +229,9 @@ Returns pandas.Dataframe. It includes the average in the first row. ### Historical Hourly Interest - pytrends.get_historical_interest(kw_list, year_start=2018, month_start=1, day_start=1, hour_start=0, year_end=2018, month_end=2, day_end=1, hour_end=0, cat=0, geo='', gprop='', sleep=0) +```python +pytrends.get_historical_interest(kw_list, year_start=2018, month_start=1, day_start=1, hour_start=0, year_end=2018, month_end=2, day_end=1, hour_end=0, cat=0, geo='', gprop='', sleep=0) +``` Parameters @@ -243,7 +254,9 @@ Returns pandas.Dataframe ### Interest by Region - pytrends.interest_by_region(resolution='COUNTRY', inc_low_vol=True, inc_geo_code=False) +```python +pytrends.interest_by_region(resolution='COUNTRY', inc_low_vol=True, inc_geo_code=False) +``` Parameters @@ -268,7 +281,9 @@ Returns pandas.DataFrame ### Related Topics - pytrends.related_topics() +```python +pytrends.related_topics() +``` Returns dictionary of pandas.DataFrames @@ -276,7 +291,9 @@ Returns dictionary of pandas.DataFrames ### Related Queries - pytrends.related_queries() +```python +pytrends.related_queries() +``` Returns dictionary of pandas.DataFrames @@ -284,8 +301,10 @@ Returns dictionary of pandas.DataFrames ### Trending Searches - pytrends.trending_searches(pn='united_states') # trending searches in real time for United States - pytrends.trending_searches(pn='japan') # Japan +```python +pytrends.trending_searches(pn='united_states') # trending searches in real time for United States +pytrends.trending_searches(pn='japan') # Japan +``` Returns pandas.DataFrame @@ -293,8 +312,10 @@ Returns pandas.DataFrame ### Realtime Search Trends - pytrends.realtime_trending_searches(pn='US') # realtime search trends for United States - pytrends.realtime_trending_searches(pn='IN') # India +```python +pytrends.realtime_trending_searches(pn='US') # realtime search trends for United States +pytrends.realtime_trending_searches(pn='IN') # India +``` Returns pandas.DataFrame @@ -302,7 +323,9 @@ Returns pandas.DataFrame ### Top Charts - pytrends.top_charts(date, hl='en-US', tz=300, geo='GLOBAL') +```python +pytrends.top_charts(date, hl='en-US', tz=300, geo='GLOBAL') +``` Parameters @@ -320,7 +343,9 @@ Returns pandas.DataFrame ### Suggestions - pytrends.suggestions(keyword) +```python +pytrends.suggestions(keyword) +``` Parameters @@ -335,7 +360,9 @@ Returns dictionary ### Categories - pytrends.categories() +```python +pytrends.categories() +``` Returns dictionary