Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: Web browsing from a batch file?



On Tue, Sep 22, 1998 at 02:32:12PM +0000, Darren Cook wrote:
> Is it possible to have a batch file (started by cron each night) access a
> web server and then email the resulting HTML page? Is this something best
> done in perl? Can it be done with perl -e do you think?

Do you want a text rendering of the page?
lynx -dump "http://www.tpc.ml.org/" -auth=jwt:bubba
(the -post_data switch can also be handy for filling in forms)

I rarely want the whole page, so I use Python to fetch a number of things
and build up a couple of custom pages every morning.  urllib will do the
fetching.  htmllib can be used for parsing... or just use regular
expressions to pick out the data of interest and generate your own
summary.

>>> import urllib, string, smtplib
>>> uo = urllib.urlopen("http://www.tpc.ml.org/")
>>> page = uo.readlines()
(Here you can use regular expressions to single out just the
comic^H^H^H^H^Hdata you are interested in on each source page.
I normally just leave the pages lying on the machine that I
create them on... but you could mail them...)
>>> page = "From: webber\nTo: jwt\nSubject: TPC\n\n" + string.join(page)
>>> s = smtplib.SMTP("mail.dskk.co.jp")
>>> result = s.sendmail("jwt-tlug@example.com", ["jwt-tlug@example.com"], page)

(On the Windows platform you can also use Python to control MSIE through
COM, but I won't mention that on the TLUG forum.)

-- 
Jim Tittsler, Tokyo   ICQ: 5981586


---------------------------------------------------------------
Next Meeting: 10 October, 12:30 Tokyo Station Yaesu central gate
Next Nomikai: 20 November, 19:30  Tengu TokyoEkiMae 03-3275-3691
---------------------------------------------------------------
Sponsor: PHT, makers of TurboLinux http://www.pht.co.jp


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links