0

I am using Kimono Labs to scrape a bunch of websites. I'd like to append "/critic-reviews" to the end of a url Kimono allows regex only in this format -

/^()(.*?)()$/

I have a bunch of URLs in this representative format -

http://www.metacritic.com/game/playstation-4/disney-infinity-30-edition

2 Answers2

1

Try to add this function in "Modify results" :

function transform (data) {
   function add_url(item) {
        item.title.href += "/critic-reviews";
        return item;
    }
     for (var collection in data.results) {
        data.results[collection] = data.results[collection].map(add_url);
    }


  return data;
}
bem
  • 11
  • 1
  • 1
  • 1
0

this seems to be one matching pattern?

http://www.metacritic.com/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)

http://regexone.com/lesson/kleene_operators gives you a walkthrough of how this works.

http://www.regextester.com/ and test your regex up there.

Shih-Min Lee
  • 9,350
  • 7
  • 37
  • 67
  • what are you trying to match, @GreatestEver? Kimono labs docs seem to indicate that the three parts of your regex match the pre, pattern, and post parts. What pattern are you trying to match? everything after metacritic.com/ ? Just the part after the last slash? (eg "disney-infinity-30-edition")? What's the "/critic-reviews" stuff you're talking about? How do you use a regex to append something to urls? Regex matches patterns, it doesn't add text to urls. I don't even understand what you're asking. – Jon Marnock Sep 01 '15 at 03:37