How can I make the links in the URL column clickable? It would be important that not the entire URL is displayed, but perhaps only "To the article" is displayed, so that the URL behind "To the article" is deposited?
import smtplib
import pandas as pd
from GoogleNews import GoogleNews
ssl._create_default_https_context = ssl._create_unverified_context
googlenews = GoogleNews()
googlenews.set_encode('utf_8')
googlenews.set_lang('en')
googlenews.set_period('7d')
orte = ["Munich", "New York", "Madrid", "London", "Los Angeles", "Frankfurt", "Rom"]
Nachrichten = []
for ort in orte:
googlenews.clear()
googlenews.get_news(ort)
table_new = []
for row in googlenews.results():
table_new.append({
'City': ort,
'Title': row['title'],
'Date': row['date'],
'URL':row['link'],
'Source': row['site'], })
df = pd.DataFrame(table_new)
nachrichten.append(df)
dfges = pd.concat(nachrichten, axis='index')
print(dfges)
´´´
CodePudding user response:
Your raw URLs are not valid. To turn them into valid Google News URLs you want to add row['link'].replace('/./article', '/article')
and add the https://
prefix. Options to obtain the real link, have been discussed