![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,233
|
perl question
is their something like mechanize for a local file?
Code:
#!/usr/local/bin/perl use WWW::Mechanize; binmode(STDOUT, ":utf8"); my $url = "http://domain.com/bookmarks.html"; my $mech = WWW::Mechanize->new(); $mech->get( $url ); my @links = $mech->links(); foreach my $link (@links) { print $link->url() . "|" . $link->text() . "\n"; }
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
No idea.. I've always user HTML::TokeParser
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
It's 42
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
|
split=/regex/ works
This looks sort of nasty but works.
I used a Firefox bookmarks file. Some adjustments to the splits might be necessary for their regexes ... You don't need to use some complex module to manipulate a line of text in Perl. Perl has a very complex and efficient regex engine in its core distribution. I am sure there are more elegant ways to regex this but this works ![]() Code:
#!/usr/bin/perl #################################### #bookmarkfile.cgi # # # # #################################### use CGI::Carp qw/fatalsToBrowser/; use CGI qw/:standard/; use strict; use warnings; print "Content-type: text/html\n\n"; my $mystuff = "$ENV{'QUERY_STRING'}"; if ($mystuff =~ s/[^a-zA-Z0-9\_]//g) {print qq~HUH???~; exit;} my $bookmarkfile="barry-bookmarks-6-2010.html"; open BOOKMARKFILE ,"<",$bookmarkfile or die "<bookmarkfile"; #######SAMPLE LINE # <DT><A HREF="http://trends.google.com/websites?q=xlovecam.com&geo=all&date=all&sort=0 #" ADD_DATE="1274745854" LAST_MODIFIED="1274745854">Google Trends for Websites: xlovecam.com</A> ####### my @bookmarks=(<BOOKMARKFILE>); my @urls = grep /(http:)/, @bookmarks; foreach my $urls (@urls){ my @a= split /HREF=\"/, $urls; my @b= split /" ADD_DATE/,$a[1]; my @anchor1 = split />/, $a[1]; my @anchor = split /</, $anchor1[1]; print "$b[0]|$anchor[0]<br/>\n"; } Code:
http://trends.google.com/websites?q=xlovecam.com&geo=all&date=all&sort=0|Google Trends for Websites: xlovecam.com |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: Feb 2011
Location: La Isla Bonita Power Level: ❤❤❤❤❤❤❤❤❤❤
Posts: 886
|
I will ask my girl later, she does a lot of Perl. Myself, I've always preferred Python over Perl, much cleaner etc.
__________________
![]() ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,233
|
actually instead of http://domain.com/bookmarks.html file:bookmarks.html works
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
It's 42
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
|
open the read file <
open the write file if necessary > or >> print WRITEFILE "data ...\n"; If a module will handle many events install it. Problem is in the module installation. There are a lot of cases where users do not have access to root and use of the CPAN shell. Considering your prior attempt at using sed for this, I am assuming this is for local use of some sort. WWW::Mechanize is an interesting module. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
there's no $$$ in porn
Industry Role:
Join Date: Jul 2005
Location: icq: 195./568.-230 (btw: not getting offline msgs)
Posts: 33,063
|
could always use the update_html method </ugly hack>
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 | |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,233
|
Quote:
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
|
![]() |
![]() ![]() ![]() ![]() ![]() |