I'm trying to get both the label and data of items of a museum collection using Rcrawler. I think I made a mistake using the ExtractXpathPat
variable, but I can't figure out how to fix it.
I expect an output like this:
1;"Titel(s)";"De StaalmeestersDe waardijns van het Amsterdamse lakenbereidersgilde, bekend als ‘De Staalmeesters’"
1;"Objecttype";"Schilderij"
1;"Objectnummer";"SK-A-2931"
However the output file repeats the title in the 3rd position:
1;"Titel(s)";"De StaalmeestersDe waardijns van het Amsterdamse lakenbereidersgilde, bekend als ‘De Staalmeesters’"
1;"Objecttype";"De StaalmeestersDe waardijns van het Amsterdamse lakenbereidersgilde, bekend als ‘De Staalmeesters’"
1;"Objectnummer";"De StaalmeestersDe waardijns van het Amsterdamse lakenbereidersgilde, bekend als ‘De Staalmeesters’"
The HTML looks like this:
<div class="item">
<h3 class="item-label h4-like">Objectnummer</h3>
<p class="item-data">SK-A-2931</p>
</div>
My method looks like this:
Rcrawler(Website = "https://www.rijksmuseum.nl/nl/",
no_cores = 4, no_conn = 4,
dataUrlfilter = '.*/collectie/.*',
ExtractXpathPat = c('//*[@class="item-label h4-like"]', '//*[@class="item-data"]'),
PatternsNames = c('label','data'),
ManyPerPattern = TRUE)
Clarification of goal The HTML page doesn't always have the same labels and sometimes it has labels without the corresponding data. Sometimes the data is in a paragraph and sometimes in an unordered list.
My end goal is to create a csv that has all the labels of the site with the corresponding data in each row.
This question is to get to the first step of collecting the labels and data, which I will then use to create the above mentioned csv.