New answers tagged python-requests
4
votes
News API in Python - Take II
Session
This may not a big deal since you are using requests at only one place, but using a session has some benefits. You can set all your headers at session level ...
4
votes
Accepted
News API in Python - Take II
Reinventing the wheel
The following loop simply reinvents next.
...
5
votes
News API in Python - Take II
Type hints
I like the usage of type hints for your functions. However, the return hint
looks wrong for:
def clean_query(text: str) -> str:
The function always ...
4
votes
News API in Python
Just a high-level comment: A large part of the code consists of rule-based parsing of text (all the string-replace calls). This is extremely brittle (there are lots of cases that you won't cover) and ...
13
votes
Accepted
5
votes
News API in Python
single responsibility
The SRP
says that a function should do one thing well.
The expression that replaces "concerning" and other stop words
should be in a helper function.
For one thing, ...
5
votes
News API in Python
String Replacements and Matching
You should use a case-insensitive regular expression using the re.I flag to do your matching. For example:
...
10
votes
News API in Python
Naming
NewsConcerning is styled in the way PEP 8 would tell us to style a class name. As function it should be in snake case: ...
Top 50 recent answers are included
Related Tags
python-requests × 56python × 53
python-3.x × 27
web-scraping × 18
beautifulsoup × 10
http × 6
json × 5
api × 5
performance × 3
object-oriented × 3
multithreading × 3
pandas × 3
python-2.x × 2
asynchronous × 2
beginner × 1
programming-challenge × 1
design-patterns × 1
comparative-review × 1
regex × 1
console × 1
database × 1
classes × 1
authentication × 1
async-await × 1
stream × 1