Manipulate string in URL in a loop
I want to generate an URL for The Guardian API. When querying a search word (here "Brexit"), the API returns the first 10 hits of the list in JSON. In order to be able to see all the results, I need to be able to change the 'page' parameter here:https://content.guardianapis.com/search?page=1&q=Brexit&api-key=a2d0...
Here's an example process. What I would love is to be able to loops through all the pages, ie be able to increase the page size by 1. Any ideas would be appreciated!
< ?xml version = " 1.0 " encoding = " utf - 8 " ?> <过程版本sion="8.2.000">
<参数键= "号_of_examples" value="100"/>
https://content.guardianapis.com/search?page=3&q=Brexit&api-key=..."/> https://content.guardianapis.com/search?page=3&q=Brexit&api-key=a2d052f9-9052-4297-ac5f-5341b104e479"/>
< ?xml version = " 1.0 " encoding = " utf - 8 " ?> <过程版本sion="8.2.000">
Best Answer
-
MartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University ProfessorPosts:3,362RM Data Scientist
your XML does not work for me. There seems to be some issue?
In any case, the solution is a loop operator. Loop provides you with a macro called iteration. You can just use this in the page parameter like this:
https://content.guardianapis.com/search?page=%{iteration}&q=Brexit&api-key=XXXXX
%{iteration} is always replaced with the current iteration count.
I would recommend that you delete your API key from your initial post. APIkeys are like passwords, you don't share them.
Best,
Martin
- Head of Data Science Services at RapidMiner -
Dortmund, Germany2
Answers
Thank you, I managed to sort out the looping with a macro.