Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 4th, 2012, 02:06 PM
metabo metabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 234 metabo Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 2 Days 14 h 32 m 50 sec
Reputation Power: 0
Can perl data dumper concise replace data dumper!?

hello dear perler,

one question: i just install several modules

now i have to choice:

can perl data dumper concise

replace data dumper!?


and if so - how to call it°!?

Reply With Quote
  #2  
Old October 4th, 2012, 05:51 PM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 550 Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 5 Days 3 h 26 m 28 sec
Reputation Power: 406
It is a useful module. The point is: what do you need, exactly?

Reply With Quote
  #3  
Old October 4th, 2012, 06:34 PM
metabo metabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 234 metabo Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 2 Days 14 h 32 m 50 sec
Reputation Power: 0
many thanks

Hello dear Laurent, good evening,

many thanks for the quick reply. great to hear

Quote:
Originally Posted by Laurent_R
It is a useful module. The point is: what do you need, exactly?



running a script gave back the following;

linux-wyee:/home/martin/perl # perl kath_test_1.pl

Loosdorf Ledochowskastra�e 4 3382 Loosdorf Telefonnummer: 02754 6257 FAX-Nummer: 02754 6257-4

linux-wyee:/home/martin/perl #

the script below gives back only a result - this one;

http://katholisch.at/content/site/pfarrfinder/address/4000.html

Quote:
Loosdorf
Ledochowskastraße 4
3382 Loosdorf
Telefonnummer: 02754 6257
FAX-Nummer: 02754 6257-4


see more results:

Quote:
Maria Neustift Neustift 28 4443 Maria Neustift Telefonnummer: 07250/204 FAX-Nummer: 07250/204-4 E-Mail: pfarre.marianeustift@dioezese-linz.at
Maria Puchheim Gmundner Stra�e 1b 4800 Attnang-Puchheim Telefonnummer: 07674/62334 FAX-Nummer: 07674/62334-4 E-Mail: pfarre.mariapuchheim@dioezese-linz.at
Maria Scharten Scharten 1 4612 Scharten Telefonnummer: 07272/5210
Maria Schmolln Maria Schmolln 2 5241 Maria Schmolln Telefonnummer: 07743/2209-12 FAX-Nummer: 07743/2209-17 E-Mail: pfarre.mariaschmolln@dioezese-linz.at
Mattighofen R�merstra�e 12 5230 Mattighofen Telefonnummer: 07742/2273 0676/87765221 FAX-Nummer: 07742/2273-22 E-Mail: propsteipfarre.mattighofen@dioezese-linz.at
Mauerkirchen Pfarrhofstra�e 4 5270 Mauerkirchen Telefonnummer: 07724/2262


it does count up - that is great!!

what i want is to force the script to run from 00000 to 10000 -
the results should be stored in a csv formatted way...



therfore i did the changes:
changed the $max_page_num to the max number and change $page to the starting number.
this will only print the data to stdout (console)


now i am trying to modify it... :-)

well i have to put it to the CSV-values.

usually this can be done with use Text::CSV_XS (where the Class::CSV is based on)

a friend also suggested me using Text::CSV which will load up Text::CSV_XS or,


Well at the moment all the results will only print the data to stdout (console) im sure that i can modify it... :-)

i just installed the Text::CSV_XS

took it from here: http://search.cpan.org/~hmbrand/Text-CSV_XS-0.91/CSV_XS.pm


Now i try to figure out which attributes i do use
Laurent, what do you suggest!?


PHP Code:
#!/usr/bin/perl 
  
  ## This is how i would go about doing what i understand about what your trying todo 
  ## EXAMPLE only 
  
  
use 5.014
  use 
strict
  use 
warnings
  
  use 
WWW::Mechanize
  use 
HTML::TokeParser
  use 
Data::Dumper
  
  
my $target_url 'http://katholisch.at/content/site/pfarrfinder/address/'#base url 
  
my $page 4000#page start number 
  
my $format '.html'#ending format 
  
my $max_page_num 4100#2300 max page number 
  
  
  #loop threw the pages 
  
for (0..$max_page_num){ 
      
#get mech 
      
my $mech WWW::Mechanize->new(); 
      
#set agent 
      
$mech->agent_alias('Windows Mozilla'); 
      
      
#this combines to make the url 
      
my $url $target_url "$page"$format"
      
      
#get the page 
      
$mech->get($url); 
      
      
#get the page 
      
my $page_content $mech->content(); 
      
      
#filter the html    
      
my $html HTML::TokeParser->new(\$page_content); 
      
      
#search and match 
      
while(my $tag $html->get_tag('strong')){ 
      
      
my $text $html->get_trimmed_text('script'); 
      
      
say $text
      } 
      
      
      
      
$page++; 
      
  } 
  
  
  
1


and now i ask - how should i add he CSV-Part to the other code?!

Any and all help is greatly appreciaated,


greetings martin

Reply With Quote
  #4  
Old October 5th, 2012, 06:09 AM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 550 Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 5 Days 3 h 26 m 28 sec
Reputation Power: 406
Hi,

to print to a file instead of printing at the screen, just change:

Perl Code:
Original - Perl Code
  1. say $text;


to:

Perl Code:
Original - Perl Code
  1. print $OUT_FILE $text;


where $OUT_FILE will be a filehandle for the output file that you will have to open before getting into the for loop.

This would work for your code as it is, but it might be different if you are using the Text:CSV module which has probably dedicated functions or methods for printing CSV lines to a file (I don't use this module and don't know it, although I should probably change this because I am using CSV files from time to time ).

You should probably describe in more details what you want your output file to look like. Do you want the comma to separate the fields of the addresses, or the records?

Reply With Quote
  #5  
Old October 5th, 2012, 09:31 AM
metabo metabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 234 metabo Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 2 Days 14 h 32 m 50 sec
Reputation Power: 0
Smile

hello dear Laurent_R

many many thanks for the quick reply. Great to hear form you! I am very happy. you give me very very valuable hints and advices. This is the right thing for me.


i want to have a CVS output where the fields of the adress is seperated.

the script below gives back result like this one;
Quote:
Loosdorf

Ledochowskastraße
3382 Loostown
Telefonnummer: 0002754 6257
FAX-Nummer: 0002754 6257-4



or if we take this for example: http://katholisch.at/content/site/pfarrfinder/address/5722.html

we have the following dataset:

Dom- und Metropolitanpfarre St. Stephan
Stephansplatz 3
1010 Wien
Telefonnummer: 515 52-3530
FAX-Nummer: 515 52-3720
E-Mail: dompfarre-st.stephan@edw.or.at
Web: http://www.st.stephan.at

well i want to have seperated each datset into these bits - in other words:
if i have a dataset that delimiters and seperates the lines that are given like that

Loosdorf Ledochowskastra�e 4 3382 Loosdorf Telefonnummer: 02754 6257 FAX-Nummer: 02754 6257-4

i would be very very happy. Note: there also a Encoding issues is: see the Ledochowskastra�e - there is a sign in it "ß" so we have to take care for the iso 8859 encoding dont we!?

Well i love if you can give some hints and helping hands. That would be very very supportive. Note: this is a great gerat chance f or me to learn alot about Perl, and the options and power of Mechanize.

Look forward to hear from you

Many many greetings
metabo

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Can perl data dumper concise replace data dumper!?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap