Async Fetch
A module to fetch data from Brutalist.report website asynchronously, including topics, sources, posts, and last update time.
BrutalistFetch(connection_reuse: bool = False)
- Initializes a BrutalistFetch object with optional connection reuse. Connection reuse will work great with context manager else you have to manage the session life.async fetch_feed_topics() -> dict
- Fetches a list of topics available from the Brutalist.report homepage.async fetch_sources(topic: str = '') -> dict
- Fetches a list of available sources with optional given topic.async fetch_source_posts(source_link: str, date: datetime.date, limit: int = POSTS_MAX_LIMIT) -> dict
- Fetches posts from a source by date, optionally filtering by limit.async fetch_last_update_time() -> datetime.datetime
- Fetches the last update time from the Brutalist.report homepage.async fetch_keyword_search() -> dict
- Fetches posts from Brutalist.report website based on a given keyword on specified date, optionally filtering by limit.
BrutalistFetch
A class to fetch data from Brutalist.report website.
Connection reuse will work great with context manager else you have to manage the session life. Read about connection reuse here: https://stackoverflow.com/questions/24873927/python-requests-module-and-connection-reuse
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_reuse |
bool
|
Set |
False
|
Source code in brutalist_report/async_fetch.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
__get_page(url)
async
Fetches a web page and returns its BeautifulSoup representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The URL of the web page to fetch. |
required |
Returns:
Name | Type | Description |
---|---|---|
BeautifulSoup |
BeautifulSoup
|
A BeautifulSoup object representing the fetched web page. |
Source code in brutalist_report/async_fetch.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
__init__(connection_reuse=False)
Read about connection reuse here: https://stackoverflow.com/questions/24873927/python-requests-module-and-connection-reuse
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_reuse |
bool
|
Set |
False
|
Source code in brutalist_report/async_fetch.py
32 33 34 35 36 37 38 39 40 41 42 43 |
|
fetch_feed_topics()
async
Fetches a list of topics from the Brutalist.report homepage.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary where keys are topic names (lowercase) and values are their corresponding URLs. |
Source code in brutalist_report/async_fetch.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
fetch_keyword_search(keyword, date, limit=POSTS_MAX_LIMIT)
async
Fetches posts from Brutalist.report website based on a given keyword on specified date, optionally filtering by limit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keyword |
str
|
The keyword to search for. |
required |
date |
date
|
The date to filter posts by. |
required |
limit |
int
|
The maximum number of posts to fetch. Defaults to POSTS_MAX_LIMIT. |
POSTS_MAX_LIMIT
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the keyword, and a dictionary of posts where keys are post titles and values are their corresponding URLs. |
Source code in brutalist_report/async_fetch.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
fetch_last_update_time()
async
Fetches the last update time in PT timezone from the Brutalist.report homepage.
Returns:
Type | Description |
---|---|
datetime
|
datetime.datetime: The last update time in PT timezone. |
Source code in brutalist_report/async_fetch.py
158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
fetch_source_posts(source, date, limit=POSTS_MAX_LIMIT)
async
Fetches posts of a source from specific date, optionally filtering by limit (number of posts to retrieve).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str
|
The source name or the URL of the source to fetch posts from. |
required |
date |
date
|
The date to retrive respective dated posts from source. |
required |
limit |
int
|
The maximum number of posts to fetch. Defaults to POSTS_MAX_LIMIT. |
POSTS_MAX_LIMIT
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the source name, source link, and a dictionary of posts where keys are post titles and values are their corresponding URLs. |
Source code in brutalist_report/async_fetch.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
fetch_sources(topic='')
async
Fetches a list of sources for a given topic.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topic |
str
|
The topic name or the topic URL to fetch sources for. Defaults to all topics available. |
''
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary where keys are source names and values are their corresponding URLs. |
Source code in brutalist_report/async_fetch.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|