mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 21:14:23 +00:00
refactor: remove GitHub authentication API endpoints and add new components
- Deleted GitHub callback and authentication handler files. - Added new component for displaying headlines. - Implemented hot news feed component with external API fetching. - Created dynamic news provider page with routing. - Developed news organization about page with animations and data fetching. - Introduced a code of conduct document.
This commit is contained in:
parent
b35e96625e
commit
930713042e
20 changed files with 861 additions and 599 deletions
|
@ -36,18 +36,15 @@ soup = BeautifulSoup(html, "html.parser")
|
|||
# Find the topiccwiz element
|
||||
topiccwiz = soup.find_all("c-wiz", class_=topiccwiz_css)
|
||||
news_data = []
|
||||
index = 0
|
||||
for item in topiccwiz:
|
||||
index+= 1
|
||||
array = []
|
||||
hotarticles = item.find_all("article")
|
||||
first_article = ""
|
||||
passed_first = False
|
||||
for article in hotarticles:
|
||||
try:
|
||||
if not passed_first:
|
||||
first_title_elem = article.find('a', class_='gPFEn')
|
||||
first_title = first_title_elem.text.strip() if first_title_elem else ''
|
||||
first_article = first_title
|
||||
passed_first = True
|
||||
continue
|
||||
title_elem = article.find('a', class_='gPFEn')
|
||||
title = title_elem.text.strip() if title_elem else ''
|
||||
|
||||
|
@ -60,13 +57,17 @@ for item in topiccwiz:
|
|||
'title': title,
|
||||
'source': source,
|
||||
'link': link,
|
||||
'category': first_article
|
||||
}
|
||||
news_data.append(article_data)
|
||||
array.append(article_data)
|
||||
except Exception as e:
|
||||
print(f"Error processing article: {e}")
|
||||
continue
|
||||
|
||||
sendData = {
|
||||
index: array
|
||||
}
|
||||
news_data.append(sendData)
|
||||
|
||||
with open('news.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(news_data, f, ensure_ascii=False, indent=2)
|
||||
|
||||
|
|
1150
scraping/news.json
1150
scraping/news.json
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue