I'm going on the assumption that you "have a set of URLs" that you need to pre-filter prior to doing something else with. Based on this assumption you could use urlparse and some string patterns to filter out X percentage of the URLs in your set that are most likely non-articles.
import re as regex
from urllib.parse import urlparse
urls =['https://candid.org/privacy-policy',
'https://happify.com/health/privacy-policy',
'https://www.abstract.com/legal/customer-terms-of-service',
'https://pesa.org.au/membership/terms-of-service-and-privacy-statement',
'https://www.cnn.com/2021/01/14/economy/unemployment-benefits-coronavirus/index.html',
'https://www.nasa.gov/content/nasa-rss-feeds',
'https://www.sciencedaily.com/newsfeeds.htm',
'https://www.ndtv.com/rss']
patterns = ['privacy-policy', 'customer-terms-of-service', 'terms-of-service-and-privacy-statement', 'rss-feeds',
'newsfeeds', 'rss']
for url in urls:
split_url = urlparse(url)
possible_article = [pattern for pattern in patterns if regex.findall(pattern, split_url.path)]
if not possible_article:
print(f'Possible article: {url}')
# output
Possible article: https://www.cnn.com/2021/01/14/economy/unemployment-benefits-coronavirus/index.html
You could potentially expand the regular expression above to flag other URLs that meet common article URLs that can date strings or common keywords, such news or wirestory.
import re as regex
from urllib.parse import urlparse
urls =['https://www.ndtv.com/rss',
'https://candid.org/privacy-policy',
'https://www.sciencedaily.com/newsfeeds.htm',
'https://happify.com/health/privacy-policy',
'https://www.nasa.gov/content/nasa-rss-feeds',
'https://www.bbc.com/news/technology-55675826',
'https://www.abstract.com/legal/customer-terms-of-service',
'https://pesa.org.au/membership/terms-of-service-and-privacy-statement',
'https://www.cnn.com/2021/01/14/economy/unemployment-benefits-coronavirus/index.html',
'https://www.cnet.com/news/samsungs-galaxy-s21-upgrades-likely-wont-spell-an-end-to-galaxy-fe-or-note-lines-yet',
'https://abcnews.go.com/Politics/wireStory/trump-leave-washington-morning-bidens-inauguration-75278801?cid=clicksource_4380645_6_heads_hero_live_headlines_hed']
non_article_patterns = ['privacy-policy', 'customer-terms-of-service', 'terms-of-service-and-privacy-statement',
'rss-feeds', 'newsfeeds', 'rss']
known_article_patterns = ['\d{4}\/\d{2}\/\d{2}', 'news', 'wireStory']
for url in urls:
split_url = urlparse(url)
non_article = [pattern for pattern in non_article_patterns if regex.findall(pattern, split_url.path)]
if non_article:
pass
else:
possible_article = [pattern for pattern in known_article_patterns if regex.findall(pattern, split_url.path)]
if possible_article:
print(f'Possible article: {url}')
Possible article: https://www.bbc.com/news/technology-55675826
Possible article: https://www.cnn.com/2021/01/14/economy/unemployment-benefits-coronavirus/index.html
Possible article: https://www.cnet.com/news/samsungs-galaxy-s21-upgrades-likely-wont-spell-an-end-to-galaxy-fe-or-note-lines-yet
Possible article: https://abcnews.go.com/Politics/wireStory/trump-leave-washington-morning-bidens-inauguration-75278801?cid=clicksource_4380645_6_heads_hero_live_headlines_hed
BUT as Erwan pointing out in his comment it's not clear "how you define the difference between article and not article", so my answer is only part of a potential solution to your problem of URL classification.
It's hard to make any solid recommendation for any "out-of-the-box" solution that can meet an undefined use case.
Here are some links that might help you:
I'm still of the mindset that your use case will likely require a multi-prong approach and will need to be refined as more URLs are classified as either "an article or non-article."