Sign In with your Yahoo! ID or Join Now

Module Reference: URL Modules

This module manipulates URLs.

Module Output: url

URL Builder Module

Pipes get their data from resources on the web, and those resources are all defined by URLs. Many URLs are long and complex. Modules like Fetch Feed let you provide a URL as a starting point for a Pipe, but sometimes you'd like to control how that URL is constructed. That's what the URL Builder module does.

To see how this works, and why it can be useful, lets look at an example URL:

		http://finance.yahoo.com/rss/headline?s=yhoo
		

One of Yahoo! Finance's RSS services lets you get news feeds for companies based on their stock market ticker. The URL above returns news stories related to Yahoo! (stock ticker YHOO). To get news on another company, for example General Motors (stock ticker GM), you'd simply change the URL to:

		http://finance.yahoo.com/rss/headline?s=gm
		

URLs are built from three main parts. The first is a server name, in our example that's "finance.yahoo.com". The second part is a resource path. That's everything after the server name, up to (but not including) the question mark ("/rss/headline"). Finally, after the question mark are a series of parameters.

In our example, there's only one parameter, named s. The parameter name and its value are separated by an equal sign, giving us "s=gm" or "s=yhoo".

If we want to use this feed service in our Pipe, we can just drop a Fetch Feed module into the Editor and type the URL in. But then our Pipe is stuck reading data for just one ticker symbol. We could wire in a URL Input module, but then the user has to enter the whole URL.

The better way is to use URL Builder. This module constructs a URL for you from parts. Some parts you may type in, others you may wire in using Text User Input modules.

Our example below shows how this works.

Example: Run this Pipe | View Source

Using the Yahoo! Finance URL above, we'll build a Pipe that gets news from any Finance feed based on a user-supplied stock ticker value. To make it more useful, we'll let the user filter the feed based on a search term they provide.

In the URL Builder, the Base is set to "http://finance.yahoo.com/rss". To this we define one Path element, "headline". Finally, we define a single Query parameter, "s". We can also define a value for "s", but here we choose instead to wire a Text Input module into query value. This lets the user specify the value at run-time.

Copyright © 2014 Yahoo! Inc. All rights reserved.