Adds a list of names of featured articles from wikipedia and the script to generate them
Browse files- feat_art.py +28 -0
- feat_art.txt +0 -0
feat_art.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import string
|
| 2 |
+
import requests
|
| 3 |
+
from bs4 import BeautifulSoup
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def get_article_names(url):
|
| 7 |
+
response = requests.get(url)
|
| 8 |
+
response.raise_for_status() # Raise an error if the request failed
|
| 9 |
+
|
| 10 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
| 11 |
+
|
| 12 |
+
article_links = soup.select("p")
|
| 13 |
+
|
| 14 |
+
article_names = [a.get_text().replace(" --", "").replace("\xa0–", "") for a in article_links if a.get_text().strip()][11:-1]
|
| 15 |
+
return article_names
|
| 16 |
+
|
| 17 |
+
article_names = []
|
| 18 |
+
url = "https://en.wikipedia.org/wiki/Wikipedia:Featured_articles"
|
| 19 |
+
names = get_article_names(url)
|
| 20 |
+
article_names.extend(names)
|
| 21 |
+
|
| 22 |
+
# Save the article names to a file (one article per line)
|
| 23 |
+
output_file = "feat_art.txt"
|
| 24 |
+
with open(output_file, "w", encoding="utf-8") as file:
|
| 25 |
+
for name in article_names:
|
| 26 |
+
file.write(name)
|
| 27 |
+
|
| 28 |
+
print(f"Saved {len(article_names)} article names to {output_file}")
|
feat_art.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|