Shiny New E-Book Gizmo: The Amazon Kindle


View Full Version : Trouble rewriting Reuters...


HeffeD
02-05-2007, 08:32 PM
Hi all, I'm new to the Palm and therefore Sunrise/Plucker. I have a few channels set up, but I'd like to learn more about rewriting links.

I'm attempting to rewrite a Reuters RSS feed. The URL is http://www.microsite.reuters.com/rss/oddlyEnoughNews/

I read in another thread how to rewrite links for the Yahoo feeds as:
document.onanchorlink = function(link) {
if (link.depth == 1) {
link.uri = link.uri.replace("/news?tmpl=story&u=", "/s");
link.uri = link.uri + "&printer=1";
}
};

Looking at the before and after URLs, I can't make much sense of what is actually going on with the code because it doesn't seem to resemble the URL.

In another thread, I found this:
Hi all

I made some mistake in the pattern and rewrite rule for Reuters.

This is the right one:
Pattern rule: http://today\.reuters\.com(.*)type=(.*)
Rewrite rule: http://today.reuters.com/misc/PrinterFriendlyPopup.aspx?type=$2

Bye

Gaetano

OK, well that looks a lot more understandable. Unfortunately, I don't know how to format the script to incorporate the regex URL info.

Can anybody help me with this? Thanks in advance!

DTM
02-06-2007, 07:00 AM
The link below will take you to the Sunrise XP tutorial wiki. The discussion on the Advanced tab will get you started with how to filter and rewrite links.

http://wiki.mobileread.com/wiki/SunriseXP_tutorial

If you still have some questions, fire away and someone here should be able to help.

Laurens
02-06-2007, 07:37 AM
The JavaScript code is for the Java version of Sunrise.

The regular expressions are for Sunrise XP.

HeffeD
02-06-2007, 11:53 AM
Thanks for the help! I'm using the Java version though, so I guess it requires the script.

Is there a similar Wiki for the Java version? Or should I switch to Sunrise XP? What is the difference between the two? Does one have more features or is more current than the other?

Thanks in advance!

Edit: Nevermind, I looked at the changelog for Sunrise XP and it had a later date than the last Java update, so it looks as though Sunrise XP is more current. I've downloaded Sunrise XP and I'm converting my Sunrise channels to XP.

Now I'll see if I can figure out the regex to rewrite Yahoo RSS feeds to point to printer friendly versions of the articles.

HeffeD
02-06-2007, 01:48 PM
OK, I have a question regarding the Yahoo RSS feeds.

I'm looking at this URL
http://rss.news.yahoo.com/rss/oddlyenough

The story link format is
http://news.yahoo.com/s/ap/20070206/ap_on_fe_st/empire_state_run_up

And the printer link uses the exact same URL, but places
&printer=1;_ylt=A0WTUeFN1MhFBmgB6QwuQE4F;_ylu=X3oDM TA3MXN1bHE0BHNlYwN0bWE-
on the end. Where does all this _ylt= and _ylu stuff come from?

I attemped using a pattern of
http://news\.yahoo\.com(.*)
With a rewrite as
http://news.yahoo.com/$1&printer=1;
But that doesn't work. How can you tell it to add stuff that wasn't in the orignal URL? Would I have to account for that in the pattern? Something like
http://news\.yahoo\.com(.*)&printer=1;(.*) ? (question character not being associated with the URL pattern)

Edit: Oh, and what does "Error enumerating VFS volumes: 0x290d" mean? I've never seen this before using Sunrise XP. Everything seems to function properly, and this error doesn't show up on my Palm, only on the log on my desktop. I'm assuming it's a sync issue of some sort? My Palm thinks it's fine, but my PC has issues with what the Palm says?

Edit 2: Well, I got rid of the enumerating error by uninstalling and reinstalling without th conduit, and all seems well.

I've also found that in the web browser, you can delete all the stuff following the '&printer=1;" portion of the URL and the pages displays just fine.

So, reading through the wiki and various threads on the forum, it appears as though my rewrite is the correct format, yet it still gives me the standard article instead of the printer friendly version. Any ideas what I'm doing wrong?

Thanks in advance for any help!

DTM
02-07-2007, 08:35 PM
You were close!

Although the "regular" story is at a URL that is of the form:

http://news\.yahoo\.com(.*)

as you used in your filter, you must look at the link in the feed page. Hover on one of the links and you'll find a bunch of stuff before that. And that stuff is irrelevant. To capture the link properly, you must filter on:

(.*)//news\.yahoo\.com(.*)

which will match the link, regardless of the junk before the "http:"

Now to filter, you must use:

http://news.yahoo.com$2&printer=1;

The same as yours, except there should be no / before the $2 and the $1 in yours has become $2 here, because now $1 is the junk up to "http:", that we don't need.

HeffeD
02-07-2007, 11:00 PM
Ah, thank you DTM! That makes me very happy.

You know, I didn't even see that stuff prior to 'http:' on the RSS page because I have a Firefox extension that rewrites redirects for me. All I saw was the actual news story URL. I'll need to remember to disable that before doing this type of thing.

And that superfluous '/' after .com, my first attempts didn't have that because I figured that the (.*) in the regex pattern was taking care of that, (and it is) but when it didn't work, I tried putting it in to see if it made a difference. It didn't. That is the version I pasted in my post. Now I see that the reason it made no difference is because I wasn't actually filtering the right URL. :rolleyes5

Thanks again, I really appreciate it!

DTM
02-08-2007, 07:09 AM
You're welcome, HeffeD, and welcome to Mobileread!

Sometimes, when you're having problems like this, you never really know if the error is in the filter or the rewrite rule or both. One trick that I use (and used for this one) is to set your rewrite rule to:

www.google.com

That way, you can concentrate on getting the filter correct. When you are actually capturing your links correctly, they all get rewritten to send you to Google. At that point, you can start working on the real rewrite rule. Of course, there still may be errors in the filter, but at least you know you're catching the links.

HeffeD
02-08-2007, 10:11 AM
That's a handy tip. I don't think I would have ever thought of doing that, but it definitely allows you to think about one thing at a time instead of wondering if the problem is with the regex or the rewrite link.

Thanks again!