Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add La Vanguardia #637

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cf3f75e
add `La Vanguardia`
addie9800 Oct 15, 2024
8bf55f8
Merge branch 'add-abc' into add-la-vanguardia
addie9800 Oct 16, 2024
a0a0f7f
fix annotations
addie9800 Oct 16, 2024
0621c82
add sitemaps
addie9800 Oct 22, 2024
1ee5169
apply suggestions
addie9800 Oct 22, 2024
a1cd09c
reraise exceptions in main thread when error handling is set to `raise`
MaxDall Nov 15, 2024
261a56d
adjust exception messages
MaxDall Nov 15, 2024
26334ea
merge exception queue with result queue and better exception message
MaxDall Nov 19, 2024
0957415
Merge pull request #662 from flairNLP/fix-651
MaxDall Nov 19, 2024
162cd0a
Update `FreiePresse`
addie9800 Nov 26, 2024
0243a9e
remove duplicate selectors
addie9800 Nov 26, 2024
f64587b
remove test files
addie9800 Nov 26, 2024
f80bce6
beatify list comprehension
addie9800 Nov 26, 2024
79a5cbf
add test file for `FreiePresse` version `V1_1`
MaxDall Nov 29, 2024
5eb93ab
fix v1 images parsing
addie9800 Nov 29, 2024
eda8323
overwrite json
addie9800 Nov 29, 2024
952ec8c
Fix `Metro`
addie9800 Nov 29, 2024
8cbe5f5
Add image extraction for `Bhaskar`
addie9800 Dec 2, 2024
645441e
Update documentation from @ 0957415dc22763e7fea7397af2635779a636fbe5
addie9800 Dec 2, 2024
b80b829
Add image extraction for `TheJapanNews`
addie9800 Dec 3, 2024
27f9261
Add image extraction for `YomiuriShimbun`
addie9800 Dec 3, 2024
113e1df
Update documentation from @ 0957415dc22763e7fea7397af2635779a636fbe5
addie9800 Dec 3, 2024
2a85504
image_extraction documentation
addie9800 Dec 15, 2024
a5e5ce1
add image example to README.md
addie9800 Dec 15, 2024
960288d
update image example in README.md
addie9800 Dec 15, 2024
dc7c14f
add images to article documentation
addie9800 Dec 15, 2024
2a31d36
update `TechCrunch`
addie9800 Dec 15, 2024
d9e83ed
remove author_filter usage
addie9800 Dec 15, 2024
bcd9f8d
remove image author bloat
addie9800 Dec 15, 2024
de31f6f
guard `Optional[str]` for mypy
MaxDall Dec 16, 2024
dd2ddfb
Merge pull request #663 from flairNLP/update-freie-presse
MaxDall Dec 16, 2024
c540cbc
add image extraction for `ElPais`
MaxDall Dec 16, 2024
8bb273d
some improvements regarding printouts and documentation
MaxDall Dec 16, 2024
fc40318
fix FreeBeacon
addie9800 Dec 16, 2024
1d519db
fix FrankfurterRundschau
addie9800 Dec 16, 2024
97e7bb6
JSON reordering, clean image authors
addie9800 Dec 16, 2024
a2255bc
update Merkur
addie9800 Dec 16, 2024
e8aa4d8
json reordering
addie9800 Dec 16, 2024
6a7ffcd
json reordering
addie9800 Dec 16, 2024
3343e1f
improve image author parsing
addie9800 Dec 16, 2024
1baee60
remove selected image author bloat
addie9800 Dec 16, 2024
cf34efc
update WDR
addie9800 Dec 16, 2024
25f79d6
Merge remote-tracking branch 'origin/images' into images
addie9800 Dec 16, 2024
3799401
remove author_filter
addie9800 Dec 16, 2024
4b40a3a
remove author_filter
addie9800 Dec 16, 2024
27a6766
black
addie9800 Dec 16, 2024
3d64b09
fix pytest
addie9800 Dec 16, 2024
ab846d7
simplify credit_keywords
addie9800 Dec 16, 2024
b1a4077
Merge pull request #665 from flairNLP/fix-metro
addie9800 Dec 16, 2024
fdc74ac
Merge branch 'master' into images
addie9800 Dec 16, 2024
95f5424
update metro tests
addie9800 Dec 16, 2024
0b00838
Merge branch 'images' into add-la-vanguardia
addie9800 Dec 17, 2024
24ca744
Add image extraction for `LaVanguardia`
addie9800 Dec 17, 2024
53b8707
Update documentation from @ 1b8014f5387d82e9a36475478ba143c80d5932d9
addie9800 Dec 17, 2024
a4bf2e7
Merge branch 'add-abc' into add-la-vanguardia
addie9800 Dec 17, 2024
5e650bd
Update documentation from @ 1b8014f5387d82e9a36475478ba143c80d5932d9
addie9800 Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/supported_publishers.md
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,21 @@
</tr>
</thead>
<tbody>
<tr>
<td>
<code>LaVanguardia</code>
</td>
<td>
<div> La Vanguardia</div>
</td>
<td>
<a href="https://www.lavanguardia.com/">
<span>www.lavanguardia.com</span>
</a>
</td>
<td>&#160;</td>
<td>&#160;</td>
</tr>
<tr>
<td>
<code>ABC</code>
Expand Down
11 changes: 11 additions & 0 deletions src/fundus/publishers/es/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from fundus.publishers.es.abc import ABCParser
from fundus.publishers.es.el_mundo import ElMundoParser
from fundus.publishers.es.el_pais import ElPaisParser
from fundus.publishers.es.la_vanguardia import LaVanguardiaParser
from fundus.scraping.url import NewsMap, RSSFeed, Sitemap


Expand Down Expand Up @@ -41,3 +42,13 @@ class ES(metaclass=PublisherGroup):
RSSFeed("https://www.abc.es/rss/2.0/portada/"),
],
)
LaVanguardia = Publisher(
name=" La Vanguardia",
domain="https://www.lavanguardia.com/",
parser=LaVanguardiaParser,
sources=[
NewsMap("https://www.lavanguardia.com/newsml/home.xml"),
RSSFeed("https://www.lavanguardia.com/rss/home.xml"),
RSSFeed("https://www.lavanguardia.com/rss/internacional.xml"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be sitemaps as well https://www.lavanguardia.com/sitemap-noticias-202102.xml.gz as well as two other NewsMaps:
https://www.lavanguardia.com/sitemap-google-news.xml
https://www.lavanguardia.com/sitemap-news-agencias.xml

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah perfect, I missed them

],
)
44 changes: 44 additions & 0 deletions src/fundus/publishers/es/la_vanguardia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import datetime
from typing import List, Optional

from lxml.etree import XPath

from fundus.parser import ArticleBody, BaseParser, ParserProxy, attribute
from fundus.parser.utility import (
extract_article_body_with_selector,
generic_author_parsing,
generic_date_parsing,
generic_topic_parsing,
)


class LaVanguardiaParser(ParserProxy):
class V1(BaseParser):
_paragraph_selector = XPath("//div[@class='article-modules']//p[@class='paragraph']")
_subheadline_selector = XPath("//div[@class='article-modules']//h3[@class='subtitle']")
_summary_selector = XPath("//h2[@class='epigraph']")

@attribute
def body(self) -> Optional[ArticleBody]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector seems to have trouble parsing this article

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me, as if there is nothing we can do about it, since the content is loaded using a script. The HTML we get in Fundus seems to mostly be scripts

return extract_article_body_with_selector(
self.precomputed.doc,
paragraph_selector=self._paragraph_selector,
subheadline_selector=self._subheadline_selector,
summary_selector=self._summary_selector,
)

@attribute
def publishing_date(self) -> Optional[datetime.datetime]:
return generic_date_parsing(self.precomputed.ld.bf_search("datePublished"))

@attribute
def title(self) -> Optional[str]:
return self.precomputed.meta.get("title")

@attribute
def authors(self) -> List[str]:
return generic_author_parsing(self.precomputed.ld.bf_search("author"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some encoding errors for the author field when parsing this article.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out, it seems to be the case that, if there is this ZWSP character, it seems to be followed by information unrelated to the author, so it can safely be just removed


@attribute
def topics(self) -> List[str]:
return generic_topic_parsing(self.precomputed.meta.get("Keywords"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could argue that the topics at the page's bottom are more descriptive. What do you think?

54 changes: 54 additions & 0 deletions tests/resources/parser/test_data/es/LaVanguardia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"V1": {
"authors": [
"Maite Gutiérrez"
],
"body": {
"summary": [
"La Generalitat quiere crear una nueva tipología de vivienda protegida proveniente del mercado de segunda mano"
],
"sections": [
{
"headline": [],
"paragraphs": [
"El Govern de la Generalitat va desgranando el plan para construir 50.000 viviendas públicas hasta el 2030 que anunció el president Salvador Illa la semana pasada, para lo que movilizarán 4.400 millones de euros.",
"Entre las novedades de esta estrategia para facilitar el acceso al mercado residencial, destaca la creación de una nueva tipología de vivienda protegida “de precio limitado”, ha avanzado este martes la consellera de Territori, Habitatge i Transició Ecològica, Sílvia Paneque, tras la reunión del Consell Executiu.",
"La vivienda de precio limitado será aquella que se adquiera a través del Fondo Público de Emancipación que el Govern quiere activar en el 2025. Este Fondo estará dotado con 100 millones de euros anuales (500 millones en total) y está pensado para ayudar a los jóvenes a financiar la entrada de un piso, ya que muchos se encuentran en la situación de poder asumir el pago de una hipoteca, pero no cuentan con ahorros suficientes como para acceder al crédito dadas las condiciones de las entidades bancarias."
]
},
{
"headline": [
"Los pisos que se adquieran con el Fondo Público de Emancipación estarán topados al IPC"
],
"paragraphs": [
"El nuevo plan de ayudas financiará hasta el 20% de la compra a personas de hasta 30 años a través del Institut Català de Finances (ICF), con una bonificación de dos puntos sobre los intereses. La vivienda deberá ser de segunda mano y no mayor de 90 m², y se establecerán criterios de renta para acceder al Fondo. Los intereses se deberán abonar de forma mensual, pero el beneficiario no tendrá que devolver el importe del préstamo público hasta que no haya pagado toda la hipoteca sustraída con el banco.",
"En caso de que el propietario de la vivienda adquirida con la ayuda del Fondo quisiera vender el inmueble en un futuro, no podría hacerlo a precio de mercado. Es aquí donde entra la nueva figura de “precio limitado”. Así, solo tendría permitido aplicar la subida del IPC del período. Además, debería devolver la totalidad de la ayuda que recibió del Fondo. La Generalitat calcula que unos 12.000 jóvenes de hasta 30 años podrían beneficiarse de este plan."
]
},
{
"headline": [
"20.000 viviendas públicas construidas para el 2027-2028"
],
"paragraphs": [
"Desde el Govern argumentan que de esta manera se evita la especulación con viviendas que se hayan adquirido con ayudas públicas, a la vez que se incrementa el parque habitacional protegido con la entrada de pisos de segunda mano. “Queremos evitar que la compra de vivienda con recursos públicos se pierda luego” en el mercado de compraventa, ha subrayado la también portavoz del Executiu. Las condiciones de estos inmuebles, ha añadido, será similar a las de la vivienda de protección oficial.",
"Paneque también ha detallado la estrategia para construir vivienda protegida destinada a alquiler, que se vehiculará a través de la reserva pública de solares que el Govern quiere crear. Una vez estos solares estén inscritos en un registro, se hará una convocatoria pública para la promoción de vivienda. La Generalitat calcula que con las medidas para acortar el tiempo de ejecución -licencia temporal de obras, agilización de trámites...- se podrían disponer de unas 20.000 viviendas construidas para el 2027-2028.",
"El Govern prevé lanzar una línea de préstamos a través del ICF de 500 millones anuales destinada a operadores públicos y privados que construyan estas viviendas de alquiler y compensará a las constructoras en caso de decalaje entre el coste de la edificación y el rendimiento del alquiler. De esta manera se intenta incentivar a las empresas para acudir a la convocatoria, ya que parte de constructoras aseguran que levantar vivienda protegida no sale a cuenta. Todo ello, no obstante, está sujeto a la aprobación de los presupuestos del 2025."
]
}
]
},
"publishing_date": "2024-10-15 14:04:17+02:00",
"title": "Catalunya dará ayudas a jóvenes para la entrada de un piso pero topará los precios",
"topics": [
"catalunya",
"dará",
"ayudas",
"jóvenes",
"entrada",
"piso",
"limitará",
"precio",
"venta"
]
}
}
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/resources/parser/test_data/es/meta.info
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"ElPais_2024_10_15.html.gz": {
"url": "https://elpais.com/internacional/2024-10-15/bruselas-sondea-la-apertura-de-centros-de-deportacion-fuera-de-la-union-europea.html",
"crawl_date": "2024-10-15 17:43:35.457824"
},
"LaVanguardia_2024_10_15.html.gz": {
"url": "https://www.lavanguardia.com/economia/20241015/10022782/catalunya-dara-ayudas-jovenes-entrada-piso-limitara-precio-venta.html",
"crawl_date": "2024-10-15 20:46:17.929513"
}
}