Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[skypt] rozwiązanie małego programu
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish)
View previous topic :: View next topic  
Author Message
ar_it
Apprentice
Apprentice


Joined: 25 Feb 2006
Posts: 212
Location: Poland/Warsaw

PostPosted: Mon Sep 23, 2013 9:15 am    Post subject: [skypt] rozwiązanie małego programu Reply with quote

Witam
Potrzebny jest mi skrypt do pobierania linków od google.pl
zrobiłem sobie cos takiego
Code:

perl -e '$i=0;while($i<1000){sleep 1; open(WGET,qq/|xargs lynx -dump/);printf WGET qq{http://www.google.com/search?q=site:wp.pl+warszawa&hl=pl&start=$i&sa=N},$i+=10}' | grep "\/\/[^/]*wp.pl\/"|grep -v webcache |grep -v forum |grep -v grupy |grep -v firmy

Co daje mi wynik zaczynajacy się od
Code:

42. http://www.google.com/url?q=

a tego co jest powyżej chcialbym się bardzo pozbyć.
I teraz pytanie jak to zrobić.
_________________
ar_it
https://www.teamquest.pl/
Back to top
View user's profile Send private message
SlashBeast
Retired Dev
Retired Dev


Joined: 23 May 2006
Posts: 2922

PostPosted: Mon Sep 23, 2013 3:19 pm    Post subject: Reply with quote

Masz w jednej linijce perla, lynxa i grepa (kilka razy), toz to dramat jakis!

Przepisz to wszystko do perla. Uzyj np. LWP::Simple, perl ma bulitin jak grep i mozna nim modzic stringi jak awk'iem.
Back to top
View user's profile Send private message
Jacekalex
Guru
Guru


Joined: 17 Sep 2009
Posts: 553

PostPosted: Mon Sep 23, 2013 10:56 pm    Post subject: Reply with quote

Najlepszy jest WWW::Mechanize, a do Ajaxa lub Javascripta WWW::Scripter (działanie niemal identyczne, jak WWW::Mechanize).
Regexy masz w Perlu takie same jak w grepie, lynxa w ogóle nie potrzebujesz (WWW::Mechanize wczytuje stronę html do zmiennej), trochę rzeźbienia jest, ale warto.

Tu masz przykład skrypta, który conieco czesze ze stron internetowych:
http://jacekalex.sh.dug.net.pl/rssperl

W poszczególnych funkcjach masz przykłady użycia kilku modułów razem z regexami.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum