Good morning everyone. I've written a script to scrape posts off of an internet forum, but I'm having problems with one last part. Each post has a link in a specific location, but the link text is different on each post. Because of this, I can't program a static value in the find_link command. I thought I got around this by using the following bit of code:
$mech->find_link( text => "$PrevMsgLink"); my $topic_obj = $mech->find_link (text_regex => qr/$PrevMsgLink/i ); my $PrevMsg = $topic_obj->url;
This worked great until I ran into a post where the link had special characters: "eBay item 380565801 (Ends Jul-09-02 144739 PDT) -" When the script sees this, it dies out with the following error:

"Can't call method "url" on an undefined value at C:\Documents and Settings\Tony\Desktop\Perl\....."

So the question is, what can I do to get the script to find links with special characters? I've searched the site here, and read the manpages for the applicable modules and come up with nothing. I'll admit, I'm still a novice at all of this, and have looked right past my own answers before. Be gentle.

Thanks much in advance! tony


In reply to How can I handle special characters in mech->find_link by SpacemanSpiff

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.