Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.raspberry-pi > #10371 > unrolled thread

Success! My chron automated Pi scrape script to newsgroup post has gone online

Started byDisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com>
First post2016-01-14 11:06 -0800
Last post2016-01-15 19:04 +0000
Articles 19 — 11 participants

Back to article view | Back to comp.sys.raspberry-pi


Contents

  Success! My chron automated Pi scrape script to newsgroup post has gone online DisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com> - 2016-01-14 11:06 -0800
    Re: Success! My chron automated Pi scrape script to newsgroup post has gone online DisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com> - 2016-01-14 11:10 -0800
      Re: Success! My chron automated Pi scrape script to newsgroup post has gone online druck <news@druck.org.uk> - 2016-01-14 19:57 +0000
        Re: Success! My chron automated Pi scrape script to newsgroup post has gone online DisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com> - 2016-01-15 10:45 -0800
          Re: Success! My chron automated Pi scrape script to newsgroup post has gone online Tim Hill <tim@invalid.org.uk> - 2016-01-15 19:21 +0000
            Re: Success! My chron automated Pi scrape script to newsgroup post has gone online Dom <domafp@blueyonder.co.uk> - 2016-01-15 20:48 +0000
          Re: Success! My chron automated Pi scrape script to newsgroup post has gone online druck <news@druck.org.uk> - 2016-01-15 21:02 +0000
          Re: Success! My chron automated Pi scrape script to newsgroup post has gone online The Natural Philosopher <tnp@invalid.invalid> - 2016-01-15 21:54 +0000
          Re: Success! My chron automated Pi scrape script to newsgroup post has gone online Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-15 20:47 -0500
            Re: Success! My chron automated Pi scrape script to newsgroup post has gone online CPMDude <nospam@somewhere.net> - 2016-01-16 00:52 -0800
              Re: Success! My chron automated Pi scrape script to newsgroup post has gone online Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-16 09:03 -0500
              Top-level description of: scrape script ? noSpam@gmail.com - 2016-03-04 07:50 +0000
          Re: Success! My chron automated Pi scrape script to newsgroup post has gone online CPMDude <nospam@somewhere.net> - 2016-01-16 00:55 -0800
            Re: Success! My chron automated Pi scrape script to newsgroup post has gone online Ahem A Rivet's Shot <steveo@eircom.net> - 2016-01-16 10:07 +0000
        Re: Success! My chron automated Pi scrape script to newsgroup post has gone online "Dr. Arthur Frayn" <dr.artfrayn@nomail.com> - 2016-02-05 13:45 -0800
          Re: Success! My chron automated Pi scrape script to newsgroup post has gone online DisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com> - 2016-02-05 15:58 -0800
          Re: Success! My chron automated Pi scrape script to newsgroup post has gone online DisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com> - 2016-02-05 20:40 -0800
    Re: Success! My chron automated Pi scrape script to newsgroup post has gone online The Natural Philosopher <tnp@invalid.invalid> - 2016-01-14 19:28 +0000
      Re: Success! My chron automated Pi scrape script to newsgroup post has gone online Rob Morley <nospam@ntlworld.com> - 2016-01-15 19:04 +0000

#10371 — Success! My chron automated Pi scrape script to newsgroup post has gone online

FromDisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com>
Date2016-01-14 11:06 -0800
SubjectSuccess! My chron automated Pi scrape script to newsgroup post has gone online
Message-ID<n78rfi$7vs$1@disneywizard.eternal-september.org>
Woo-hoo! Although the trails and tribulations of bringing the spark of 
an idea to fruition were at times overwhelming, they just sweetened the 
success when it worked, on it's own even.

Short story long;
So I'm reading Monk's Python about scraping Amazon for keywords and I 
expand the exercise to grab the prices as well and sort the list by 
cheapest item first, just to play with it. I was initially drawn to his 
article by the www protocol navigation ability and was amazed at the 
revelation that nabbing a webpage was essentially a method of opening a 
file.
Later I saw  a c.s.raspberry-pi post about posting e-mail and put that 
together with a contest sweepstakes I'd just learned about. "Gee, this 
flash page sure loads fast, but takes ten minutes to render!" Getting 
the keyword in a browser blew wet mangy goats. Couldn't I just scrape 
the site and nab only the keyword? So I set about, on my msWin laptop, 
using PuTTY to command and TextPad to author Python 3 code over to my 
otherwise idle Raspberry Pi +B.  Using my getwebpage() function to snag 
the page to a string and my locate_value function  to select the page 
code which consistently precedes the contest keyword and in the bargain 
I now have written two nifty subroutines which I'll likely re-use in the 
future:
[code]

import urllib.request

def getwebpage(URL):
     rawsource = urllib.request.urlopen('http://'+URL)
     webpage = str(rawsource.read())
     rawsource.close()
     return(webpage)

import sys

import os

def locate_value(fieldname):
     valuestart = webpage.find(fieldname, 0)+len(fieldname)
     valueend = webpage.find('"', valuestart+1)
     return webpage[valuestart:valueend]

[/code]

For awhile, I'd wake up everyday before 7:00 a.m. to greet the new 
keyword as the site switched it, and that was satisfactory. I'd run 
WotD.py (Word of the Day) and post the result manually to the relevant 
newsgroup before utilizing the keyword selfishly in my own online entry 
(for tthe same reason I always feed the cat before feeding myself - that 
way I don't forget to help others after I'm satisfied.) Then I came 
across the email posting question and realized there must be a library 
for newsgroups handling and found the nntplib. For a week I messed about 
through my stupid punctuation, syntax and conceptual errors to be able 
to post a newsgroup news:alt.test.only (primarily delayed by the server 
error 'duplicate post'.)  I skipped the 'mailmerge template' style for 
now and just went with a hardcoded-into-the-script string variable 
concatenation, but I'd like to change that to a template file, a values 
file (as I've done with the loginID and password) and using a 
print.format() to insert the values into the template form (realizing 
what immense power the PI would then become to spew spam all day.) The 
wotd.py script 'push' today's keyword, or the Word of the Day, ontop of 
a WotDlog.txt file when it's done which makes it very simple to open and 
'pop' read yesterdays_wotd=WotDlog.readline() and then, in a while loop, 
wait until the website publishes the change to today's new WotD. If I 
could get the Pi to not require it to wait for me to launch the script, 
well within the capabilities of Debian OS, then I could sleep in, or 
even go on vacation. Going live meant understanding Debian's Chron to 
schedule a WotD.sh script which simply contains "python3 wotd.py" - the 
biggest trouble in that was to remember to end the launch command with 
'&' so it runs in the background, not ties up the command line. Now I 
wonder if I should make the program silent - not printing - or to 
redirect on the command line a ' > stdout' so it verifies it worked? I 
guess just peeking at the newsgroup with my laptop Thunderbird client 
would be sufficient, and return me to the ranks of data users.
Although I might learn a great deal from tacking onto the  end a script 
extension which automatically fills in the Sweepstakes entry form  with 
my WotD keyword and contact info, the thought experiment would be moot 
as the contest ends soon.

I skipped the proper practice of separating data from code just to 
'get-'er-done' quick and dirty, primarily because I was struggling with 
Python3's strong typing of data. I couldn't post because my call to 
"servers.post(open('WotDtoday.txt', 'rb'))" came back "expected string, 
not bytes" error when I was reading the template from a file, but 
confused by the fact that it accepts and publishes if it is called to 
open a file in binary. WTF? Much delay was spent in 
stringvar.encode('utf_8') and stringvar.decode('utf_8') So I hardcoded 
the result into the program then told the program to write a temporay 
'today' file which it later reads with a direct open in 
servers.post(open('WotDtoday.txt', 'rb')) , go figure. Again, poor 
pracice, quick and dirty, but it works. The code really should be MUCH 
simpler with a single line such as (but certainly miscoded)
servers.post(open('WotDtemplate.txt', 'rb').replace('WotDvalues.txt')) 
using print formatting instead
such that the template file keeps %placeholders, and the values file is 
the format string containing groups=alt.test.only, placeholder=WotD, 
newsserver=mynews.provider.com et cetera.

Attached is the way too verbose code.

Next up - another futile endevor, scrabble rack anagrams  for quick high 
values results to an online radio contest points WordHoard, which is 
going away at the end of this month, January, 2016. It has a keen sort 
and a secret - a really good, concise, dictionary to draw candidates from.

And a prosperous new year to you all —(o=8> wiz.

-- 
   All ladders in the Temple of the Forbidden Eye have thirteen steps.
There are thirteen steps to the gallows, firing squad or any execution.
  The first step is denial...                           Don't be bamboozled:
        Secrets of the Temple of the Forbidden Eye revealed!
           Indiana Jones™ Discovers The Jewel of Power!
          visit —(o=8> http://disneywizard.com/ <8=o)— visit
Raison d'êtrer? Reason for life? Cheez, can't I just set my sights on 
contributing to the betterment of society for a week?

[toc] | [next] | [standalone]


#10372

FromDisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com>
Date2016-01-14 11:10 -0800
Message-ID<n78rlo$7vs$2@disneywizard.eternal-september.org>
In reply to#10371

[Multipart message — attachments visible in raw view] — view raw

Oops, forgot the attachment, here you go!

On 1/14/2016 11:06 AM, DisneyWizard the Fantasmic! wrote:
>
> Woo-hoo! Although the trails and tribulations of bringing the spark of
> an idea to fruition were at times overwhelming, they just sweetened the
> success when it worked, on it's own even.
>
> Short story long;
> So I'm reading Monk's Python about scraping Amazon for keywords and I
> expand the exercise to grab the prices as well and sort the list by
> cheapest item first, just to play with it. I was initially drawn to his
> article by the www protocol navigation ability and was amazed at the
> revelation that nabbing a webpage was essentially a method of opening a
> file.
> Later I saw  a c.s.raspberry-pi post about posting e-mail and put that
> together with a contest sweepstakes I'd just learned about. "Gee, this
> flash page sure loads fast, but takes ten minutes to render!" Getting
> the keyword in a browser blew wet mangy goats. Couldn't I just scrape
> the site and nab only the keyword? So I set about, on my msWin laptop,
> using PuTTY to command and TextPad to author Python 3 code over to my
> otherwise idle Raspberry Pi +B.  Using my getwebpage() function to snag
> the page to a string and my locate_value function  to select the page
> code which consistently precedes the contest keyword and in the bargain
> I now have written two nifty subroutines which I'll likely re-use in the
> future:
> [code]
>
> import urllib.request
>
> def getwebpage(URL):
>      rawsource = urllib.request.urlopen('http://'+URL)
>      webpage = str(rawsource.read())
>      rawsource.close()
>      return(webpage)
>
> import sys
>
> import os
>
> def locate_value(fieldname):
>      valuestart = webpage.find(fieldname, 0)+len(fieldname)
>      valueend = webpage.find('"', valuestart+1)
>      return webpage[valuestart:valueend]
>
> [/code]
>
> For awhile, I'd wake up everyday before 7:00 a.m. to greet the new
> keyword as the site switched it, and that was satisfactory. I'd run
> WotD.py (Word of the Day) and post the result manually to the relevant
> newsgroup before utilizing the keyword selfishly in my own online entry
> (for tthe same reason I always feed the cat before feeding myself - that
> way I don't forget to help others after I'm satisfied.) Then I came
> across the email posting question and realized there must be a library
> for newsgroups handling and found the nntplib. For a week I messed about
> through my stupid punctuation, syntax and conceptual errors to be able
> to post a newsgroup news:alt.test.only (primarily delayed by the server
> error 'duplicate post'.)  I skipped the 'mailmerge template' style for
> now and just went with a hardcoded-into-the-script string variable
> concatenation, but I'd like to change that to a template file, a values
> file (as I've done with the loginID and password) and using a
> print.format() to insert the values into the template form (realizing
> what immense power the PI would then become to spew spam all day.) The
> wotd.py script 'push' today's keyword, or the Word of the Day, ontop of
> a WotDlog.txt file when it's done which makes it very simple to open and
> 'pop' read yesterdays_wotd=WotDlog.readline() and then, in a while loop,
> wait until the website publishes the change to today's new WotD. If I
> could get the Pi to not require it to wait for me to launch the script,
> well within the capabilities of Debian OS, then I could sleep in, or
> even go on vacation. Going live meant understanding Debian's Chron to
> schedule a WotD.sh script which simply contains "python3 wotd.py" - the
> biggest trouble in that was to remember to end the launch command with
> '&' so it runs in the background, not ties up the command line. Now I
> wonder if I should make the program silent - not printing - or to
> redirect on the command line a ' > stdout' so it verifies it worked? I
> guess just peeking at the newsgroup with my laptop Thunderbird client
> would be sufficient, and return me to the ranks of data users.
> Although I might learn a great deal from tacking onto the  end a script
> extension which automatically fills in the Sweepstakes entry form  with
> my WotD keyword and contact info, the thought experiment would be moot
> as the contest ends soon.
>
> I skipped the proper practice of separating data from code just to
> 'get-'er-done' quick and dirty, primarily because I was struggling with
> Python3's strong typing of data. I couldn't post because my call to
> "servers.post(open('WotDtoday.txt', 'rb'))" came back "expected string,
> not bytes" error when I was reading the template from a file, but
> confused by the fact that it accepts and publishes if it is called to
> open a file in binary. WTF? Much delay was spent in
> stringvar.encode('utf_8') and stringvar.decode('utf_8') So I hardcoded
> the result into the program then told the program to write a temporay
> 'today' file which it later reads with a direct open in
> servers.post(open('WotDtoday.txt', 'rb')) , go figure. Again, poor
> pracice, quick and dirty, but it works. The code really should be MUCH
> simpler with a single line such as (but certainly miscoded)
> servers.post(open('WotDtemplate.txt', 'rb').replace('WotDvalues.txt'))
> using print formatting instead
> such that the template file keeps %placeholders, and the values file is
> the format string containing groups=alt.test.only, placeholder=WotD,
> newsserver=mynews.provider.com et cetera.
>
> Attached is the way too verbose code.
>
> Next up - another futile endevor, scrabble rack anagrams  for quick high
> values results to an online radio contest points WordHoard, which is
> going away at the end of this month, January, 2016. It has a keen sort
> and a secret - a really good, concise, dictionary to draw candidates from.
>
> And a prosperous new year to you all —(o=8> wiz.
>

-- 
   All ladders in the Temple of the Forbidden Eye have thirteen steps.
There are thirteen steps to the gallows, firing squad or any execution.
  The first step is denial...                           Don't be bamboozled:
        Secrets of the Temple of the Forbidden Eye revealed!
           Indiana Jones™ Discovers The Jewel of Power!
          visit —(o=8> http://disneywizard.com/ <8=o)— visit

-------
[code]
#!/usr/bin/env python3
'''
Usage: python3 wotd.py

Author: DisneyWizard http://contact.disneywizard.com
'''
CONTACT='http://disneywizard.angelfire.com/contact.html#form'
URL='diamond.disneyland.disney.go.com/wotd'
GROUPSERVER='news.eternal-september.org'
GROUPS='alt.disney.disneyland' # alt.test, alt.test.only
with open('login.txt', mode='r') as loginnews:
     USER=loginnews.readline()
     PWD=loginnews.readline()
history='wotdlog.txt'
tempfile='wotdtemp.txt'
with open(history, mode='r') as read_history: # read most recent, first 
record of file
     wotd = last = read_history.readline().replace("\n", "")
print(last+", yesterday's WordOfTheDay "+URL), # a quick first print 
assures users that the script is working

import urllib.request
import sys
import os
import time
import nntplib
import string
from datetime import datetime, timedelta
from subprocess import call
from string import Template

def getwebpage(URL):
     rawsource = urllib.request.urlopen('http://'+URL)
     webpage = str(rawsource.read())
     rawsource.close()
     return(webpage)
def locate_value(fieldname):
     valuestart = webpage.find(fieldname, 0)+len(fieldname)
     valueend = webpage.find('"', valuestart+1)
     return webpage[valuestart:valueend]

#print( "Start : %s" % time.ctime())
#time.sleep( 5 )
#print( "End : %s" % time.ctime())

if __name__ == "__main__":
     pass
#---------scrape Word of the Day----------
while wotd == last:
     #print(wotd+"%s"  % time.ctime(), end='',); sys.stdout.flush() 
#testing timer
     #time.sleep( 1 )
     webpage=getwebpage(URL) #load the webpage
     #print("%s" % time.ctime(), end=''); sys.stdout.flush() #testing timer
     wotd=locate_value('{"items":[{"title":"') # search for value after 
this key
print(wotd)

#--------message text-----------

message=("Reply-To: ")
message+=CONTACT+"\nSubject: Re: [WotD] "
message+=wotd+"\nReferences: 
<mvoj9p$o2a$1@disneywizard.eternal-september.org>\nNewsgroups: "
message+=GROUPS+"\nFrom: DisneyWizard the Fantasmic! 
<wiz@FANTASMIC!disneywizard.com>\nOrganization: Practcally perfect in 
every way "
message+=CONTACT+"\nUser-Agent: Custom hand coded Python3 automated 
chron/nntp script on Raspberry Pi 1B\nMIME-Version: 1.0\nIn-Reply-To: 
<mvoj9p$o2a$1@disneywizard.eternal-september.org>\nContent-Type: 
text/plain; charset=utf-8; format=flowed\nContent-Transfer-Encoding: 
8bit\n\n"
message+=wotd+"\n\nOn 10/15/2015 9:14 AM, DisneyWizard the Fantasmic! 
wrote:\n> https://diamond.disneyland.disney.go.com/wotd\n>\n> 
https://disneydiamonddays.com/ to enter\n>\n\n"
print(message+'\n\n')
#--------create outfile------------
with open('signature.txt', 'r') as signature:
     with open('WotDtoday.txt', 'w') as todaysmessage:
         todaysmessage.writelines([item for item in message])
         todaysmessage.writelines([item for item in signature])

# ----send outfile to server-------
s = nntplib.NNTP(GROUPSERVER, 119)
s.login(USER, PWD)
s.post(open('WotDtoday.txt', 'rb'))
s.quit()


print ("Success!"),# posted to

#-----push WotD onto top of WotD log----

with open(tempfile, mode='w') as write_log, open(history, mode='r') as 
read_history:
     write_log.write(wotd+'\n') # add today's word-of-the-day on top
     for line in read_history: #then fill the log with previous log (by 
decending date)
         write_log.write(line) #write_log.write(line.replace('\n', '')+'\n')
     write_log.flush()
     os.fdatasync(write_log)

call(["mv", tempfile, history]) # rename (move) tempfile to history

#---confirm success------------
resultline = locate_value('"wotd_body":"')\
+' has been posted as the Word of the Day to '+GROUPS+'!'

print(resultline) #reassures the user all processes are closed

raise SystemExit
[/code]

[toc] | [prev] | [next] | [standalone]


#10375

Fromdruck <news@druck.org.uk>
Date2016-01-14 19:57 +0000
Message-ID<n78udp$hnq$1@dont-email.me>
In reply to#10372
On 14/01/2016 19:10, DisneyWizard the Fantasmic! wrote:
> Oops, forgot the attachment, here you go!

DO NOT attach any type of file to posts in a _text_only_ newsgroup.

---druck

[toc] | [prev] | [next] | [standalone]


#10384

FromDisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com>
Date2016-01-15 10:45 -0800
Message-ID<n7bejl$2vu$1@disneywizard.eternal-september.org>
In reply to#10375
Druck, you self appointed net cop who contributed nothing to the 
conversation and offered absolutely NO assistance or constructive 
suggestion:

Did the server reject the attachment it? No.
Confuse not files which are binaries with attached TEXT files, or 
fucking ban me, I dare you.

No binaries is a CONVENTION, and, by the way, there are ways around no 
binaries conventions.
You could certainly post an article which contains an <imbed> picture, 
move, audio stream, RSS feed, none of which is a huge binary propagated 
by the nntp news-servers. Imbeds are instead references to immense files 
on a single remote server - which leaves up to each reader to continue 
the message or not.

Is this group a big eight, like rec? No. Is it moderated? No. Is it alt? NO!
Why does alt exist, and what does the acronym stand for?
Alt was created a response to overzealous, self-important, free-thought 
choking moderation in the big-8
Alt is an acronym for Aliens, Lunatics and Terrorists - as a place where 
alternative viewpoints, unconventional  thoughts, and those on the wrong 
side of history, sports, politics et cetera, can flourish unfettered. 
Even criminals. In my religion, it is a crime to tell someone what to 
do, which you have just done to me, which makes you a criminal - welcome 
to c.s.rasperry-pi.

Do you even know what NNTP protocol does, or how it loosely propagates 
articles among the benevolent servers run by altruistic admins. Each 
admin sets the limits that THEIR OWN server provides resources to each 
group. Having a convention such as 'no binaries' allows more, older, 
messages to remain longer before falling off each servers message queue, 
as pictures and movies tend to suck NNTP propagation bandwidth and 
reduce the count of articles retained. Now having explained that, please 
produce the charter for news:comp.sys.raspberry-pi (I was there, at the 
beginning by the way) and show me where it says "no attachments" please. 
And even if it did, regardless, that would still only represent a 
guideline for each news server admin to accept or reject attachments, or 
messages which contain them as they choose to store and forward. If you 
had asked nicely, I'd have simply explained how  attachments can improve 
the reader experience by allowing them to choose what they read while 
offering a machine readable code segment if they so choose without 
severely degrading the group propagation performance .

I propose that attachments are indeed an excellent idea for the entire 
comp.sys.* hierarchy for including complete scripts and source code. If 
you don't want to read it then don't click the ''download attachment" 
and if you do it's a machine readable complete unit which doesn't 
introduce operator error cutting and pasting from the message pane of 
the users news client. But as far as the participating news servers are 
concerned with propagation, bandwidth, and storage resources,  pasting 
the code to the bottom versus including it as an attachment is 
functionally identical to the servers-cloud.

And for that opinion you should not ban me.

You should ban me for THIS opinion and subsequent suggestion:
As your apparent purple lips betray you as the consort to a wet mangy 
goat, you don't need to, but you probably should, go fuck yourself. 
(Please take notice of the phrasing, I'm not telling you what to do, as 
long as you're not asking.)

By the way, I will disregard your demanding demented misinformed opinion 
of 'no attachments' and continue to make the world a better place as I 
see fit, for I too am a self appointed net cop, which means I'll post 
attachments as necessary. And also by the way, I have been appointed a 
net admin, hired as an auditor, as well as commissioned both a judge and 
a judges examiner by DARPA - so take me to net-court and I'll stand my 
sentence.

On 1/14/2016 11:57 AM, druck wrote:
> On 14/01/2016 19:10, DisneyWizard the Fantasmic! wrote:
>> Oops, forgot the attachment, here you go!
>
> DO NOT attach any type of file to posts in a _text_only_ newsgroup.
>
> ---druck
>

OMG! Where's the kind request?  Where's the explanation of what compels 
  you to be or offer an example, such as… "May I show you how to improve 
your life" or even "Allow me to provide an answer to the meaning of life 
and how you would benefit while making the world a better place."
So, Druck, you self appointed net cop who contributed nothing to the 
conversation and offered absolutely NO assistance or constructive 
suggestion - only your knee-jerk selfish reaction as a personally 
directed screaming complaint. Here in the land of free-speech that is 
allowed, but do realize that comes with consequences such as how others 
perceive you constructing your character with your words. I do so as 
well, as a certified Honorable Reverend Doctor of the Church of Pull 
Your Head out of Your Ass - for I am bound by oath to tell it like it 
is, to reveal the truth as I attempt to remove the 'as I see it' filter. 
Your unfounded COMMAND "DO NOT attach any type of file to posts in a 
_text_only_ newsgroup" offends me deeply - as a complaint. just so much 
noise in a ratio of signal. Here in the land of free speech, folks who 
only complain that others aren't doing as they wish are widely knows as 
BITCHES BITCHING. And now you will forever be my bitch. Flame on , bitch.

-- 
- better to learn by mistakes of others, - Wiz.
- erroneous examples as provided, - Wiz.
- than to learn by mistakes made for oneself. - Wiz.
- A bakers dozen out of 12 Wizards agree: "And far less painful. - Wiz."
Anarchy has gotten a bad rap from punks using it as an excuse to harm 
others.
The true origin of Anarchy was like Bushido Code of the Samuri, each man
striving to improve themselves and facilitating a better world, 
independently
self policing, and without the need of nor corruption resulting from 
Imperial Rule.

[toc] | [prev] | [next] | [standalone]


#10386

FromTim Hill <tim@invalid.org.uk>
Date2016-01-15 19:21 +0000
Message-ID<55427908aatim@invalid.org.uk>
In reply to#10384
In article <n7bejl$2vu$1@disneywizard.eternal-september.org>,
   DisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com> wrote:
> Druck, you self appointed net cop 

He's always right though! 
Over at c.s.acorn.* the Druckster is revered. 
Or something like that.

[Snip - the irrelevant ranting of a loon]

* plonk *

(The best New Year's Resolution Ever: B.E.T. - Block Every Twerp.)

[toc] | [prev] | [next] | [standalone]


#10387

FromDom <domafp@blueyonder.co.uk>
Date2016-01-15 20:48 +0000
Message-ID<vWcmy.36729$Mi6.34321@fx35.am4>
In reply to#10386
On 15/01/16 19:21, Tim Hill wrote:
> In article <n7bejl$2vu$1@disneywizard.eternal-september.org>,
>     DismalWizard the Failure <who-cares?> wrote:
>> Druck, you self appointed net cop
>
> He's always right though!
> Over at c.s.acorn.* the Druckster is revered.
> Or something like that.

I thought I recognised the name from somewhere :)

[toc] | [prev] | [next] | [standalone]


#10388

Fromdruck <news@druck.org.uk>
Date2016-01-15 21:02 +0000
Message-ID<n7bmjq$2hj$1@dont-email.me>
In reply to#10384
On 15/01/2016 18:45, DisneyWizard the Fantasmic! wrote:

> Is this group a big eight, like rec? No.

Comp is.

[snip]

tl;dr

---druck

[toc] | [prev] | [next] | [standalone]


#10389

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2016-01-15 21:54 +0000
Message-ID<n7bpr5$p3a$3@news.albasani.net>
In reply to#10384
On 15/01/16 18:45, DisneyWizard the Fantasmic! wrote:
> Druck, you self appointed net cop who contributed nothing to the
> conversation and offered absolutely NO assistance or constructive
> suggestion:
>
>

DisneyWizard you self appointed revolutionary who contributed nothing to 
the group and offered absolutely NOTHING of interest:

He who shits in the group gets plonked on his return

*plonk*


-- 
You can get much farther with a kind word and a gun than you can with a 
kind word alone.

Al Capone

[toc] | [prev] | [next] | [standalone]


#10391

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2016-01-15 20:47 -0500
Message-ID<m78j9btofnids4h2qkdddcggrc1vot8jql@4ax.com>
In reply to#10384
On Fri, 15 Jan 2016 10:45:28 -0800, DisneyWizard the Fantasmic!
<wiz@FANTASMIC!disneywizard.com> declaimed the following:

>
>Is this group a big eight, like rec? No. Is it moderated? No. Is it alt? NO!

	Since I'm seeing this as COMP.sys.raspberry-pi, I suspect it does
qualify as "big-8", even if not moderated.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#10392

FromCPMDude <nospam@somewhere.net>
Date2016-01-16 00:52 -0800
Message-ID<n7d0bj$jt2$1@gioia.aioe.org>
In reply to#10391
On 1/15/2016 5:47 PM, Dennis Lee Bieber wrote:
> On Fri, 15 Jan 2016 10:45:28 -0800, DisneyWizard the Fantasmic!
> <wiz@FANTASMIC!disneywizard.com> declaimed the following:
>
>>
>> Is this group a big eight, like rec? No. Is it moderated? No. Is it alt? NO!
>
> 	Since I'm seeing this as COMP.sys.raspberry-pi, I suspect it does
> qualify as "big-8", even if not moderated.
>

Yep, the stupid drunken twit who 'thinks' he knows everything
about NNTP, Usenet policy, history, and conventions (*ahem*)
can't even figure out that he's cross-posting.  Disney-whatever
is a fitting name - he's Dopey from the Seven Dwarfs in cognito!

*plonk*

[toc] | [prev] | [next] | [standalone]


#10397

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2016-01-16 09:03 -0500
Message-ID<pbjk9b1comlepl6slfe7fi7ipa78dv456l@4ax.com>
In reply to#10392
On Sat, 16 Jan 2016 00:52:01 -0800, CPMDude <nospam@somewhere.net>
declaimed the following:

>Yep, the stupid drunken twit who 'thinks' he knows everything
>about NNTP, Usenet policy, history, and conventions (*ahem*)
>can't even figure out that he's cross-posting.  Disney-whatever
>is a fitting name - he's Dopey from the Seven Dwarfs in cognito!
>
	That's an insult... Dopey didn't spend his life spewing random beliefs
to the world. <G>
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#10975 — Top-level description of: scrape script ?

FromnoSpam@gmail.com
Date2016-03-04 07:50 +0000
SubjectTop-level description of: scrape script ?
Message-ID<nbbeo2$dng$1@dont-email.me>
In reply to#10392
In article <n7d0bj$jt2$1@gioia.aioe.org>, CPMDude <nospam@somewhere.net> wrote: 

> On 1/15/2016 5:47 PM, Dennis Lee Bieber wrote:
> > On Fri, 15 Jan 2016 10:45:28 -0800, DisneyWizard the Fantasmic!
Apart from knocking the author, do any readers know what his
code does?
Doesn't python use subroutines?
--
OK: 
 getwebpage(URL) returns webpage;
 locate_value(fieldname) returns webpage(<per fieldname>);
 
 Let's evaluate the ideas & code, and not be football-hooligans.
 Or is it the pending US elections that's got your hormones going?
 

[toc] | [prev] | [next] | [standalone]


#10393

FromCPMDude <nospam@somewhere.net>
Date2016-01-16 00:55 -0800
Message-ID<n7d0ic$k5p$1@gioia.aioe.org>
In reply to#10384
On 1/14/2016 10:45 AM, DisneyWizard the Fantasmic! wrote:

>>> Oops, forgot the attachment, here you go!
>>  [lots of meaningless drivel snipped]

That script is kiddie-python-101.  It doesn't belong here.

[toc] | [prev] | [next] | [standalone]


#10396

FromAhem A Rivet's Shot <steveo@eircom.net>
Date2016-01-16 10:07 +0000
Message-ID<20160116100736.9b6f65775fd126f35b79ed00@eircom.net>
In reply to#10393
On Sat, 16 Jan 2016 00:55:39 -0800
CPMDude <nospam@somewhere.net> wrote:

> On 1/14/2016 10:45 AM, DisneyWizard the Fantasmic! wrote:
> 
> >>> Oops, forgot the attachment, here you go!
> >>  [lots of meaningless drivel snipped]
> 
> That script is kiddie-python-101.  It doesn't belong here.

	If it were my kiddie python 101 course it would get a poor grade.

-- 
Steve O'Hara-Smith                          |   Directable Mirror Arrays
C:>WIN                                      | A better way to focus the sun
The computer obeys and wins.                |    licences available see
You lose and Bill collects.                 |    http://www.sohara.org/

[toc] | [prev] | [next] | [standalone]


#10547

From"Dr. Arthur Frayn" <dr.artfrayn@nomail.com>
Date2016-02-05 13:45 -0800
Message-ID<LJ8ty.621776$bU4.545655@fx37.am4>
In reply to#10375

On 1/14/2016 11:57 AM, druck wrote:
> On 14/01/2016 19:10, DisneyWizard the Fantasmic! wrote:
>> Oops, forgot the attachment, here you go!
>
> DO NOT attach any type of file to posts in a _text_only_ newsgroup.
>
> ---druck
>

So, no one has truly contributed anything but DisneyWizard. Instead 
everyone who replied is "Talking About Talking About It." Much more 
bandwidth consumed slinging insults and complaints but not one 
constructive answer or even an offer of the text of the charter (which 
doesn't ban attachments.) Shame on you all for misparticipation.

DisneyWizard: Escape the delimiter.
Did you remember to double the existing dollar-signs ($) in your 
template file? A single dollar-sign indicates a replacement field, 
unless you double it and the swap interprets it as source text and 
passes it through as a single $, and not to interpret the double $$ as a 
start delimiter of a field name.

-- 
http://dr.zardoz.angelfire.com/zardoz/ until the Eternals!

[toc] | [prev] | [next] | [standalone]


#10548

FromDisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com>
Date2016-02-05 15:58 -0800
Message-ID<n93cp8$omf$1@disneywizard.eternal-september.org>
In reply to#10547

[Multipart message — attachments visible in raw view] — view raw

On 2/5/2016 1:45 PM, Dr. Arthur Frayn wrote:
>
>
> On 1/14/2016 11:57 AM, druck wrote:
[snip drucks bullshit]
>> ---druck
>>
>
> So, no one has truly contributed anything but DisneyWizard. Instead
> everyone who replied is "Talking About Talking About It." Much more
> bandwidth consumed slinging insults and complaints but not one
> constructive answer or even an offer of the text of the charter (which
> doesn't ban attachments.) Shame on you all for misparticipation.
>
> DisneyWizard: Escape the delimiter.
> Did you remember to double the existing dollar-signs ($) in your
> template file? A single dollar-sign indicates a replacement field,
> unless you double it and the swap interprets it as source text and
> passes it through as a single $, and not to interpret the double $$ as a
> start delimiter of a field name.
>

Ah ha! Thanks Art! (may I call you Art?) You were right!

The problem was in the template text file. The lines:
Message-ID: <n8vouu$qr8$1@disneywizard.eternal-september.org>
References: <mvoj9p$o2a$1@disneywizard.eternal-september.org>
were halting execution! Each contained two $,  which the python code was 
halting at when it couldn't find a matching keyword for '$qr8' and '$1'
That and I misread the error codes thinking 'qr8' was a compiler 
supplied description, not supplied by my template file.

========================
Code Gurus:
    Is there a shorter, perhaps one line, way to condense this 
definition 'getwebpage'? Perhaps without the intermediate rawsource or 
webpage variables?

SKIMURL='somewebsite.com/page.html'

def getwebpage(SKIMURL):
     rawsource = urllib.request.urlopen('http://'+SKIMURL)
     webpage = str(rawsource.read())
     rawsource.close()
     return(webpage)

Such as

def getwebpage(SKIMURL):
     return(str((urllib.request.urlopen('http://'+SKIMURL)).read()))

or even eliminating the definition, reducing it to inline code and replace:
     webpage=getwebpage(SKIMURL) #load the webpage
with
     webpage =  (str((urllib.request.urlopen('http://'+SKIMURL)).read()))
which I can't get to work, or close the rawsource

and would that  improve execution speed?

Q2: Is there a 'mailmerge' way to read the template once and post a 
message to each merged addressee? Point me to similar working code 
please? This code seems far too verbose for something I used to do in 
two APL lines. (well, I never opened a webpage like a file in APL, but 
the source|merge>out was two lines.) I've got two tempfiles to get it to 
work. But without WotDtoday.txt I get strong type mismatch errors as I 
haven't figured out how to successfully translate the 'message' template 
byte stream into text for the server.post(message) directly. It's not 
iterating properly as a direct post.
How do I eliminate the intermediate file in:

#--------create outfile------------
with open(TODAY, 'w') as todaysmessage:
     todaysmessage.writelines([item for item in message])

# ----send outfile to server-------
s = nntplib.NNTP(GROUPSERVER, 119)
s.login(USER, PWD)
s.post(open(TODAY, 'rb'))
s.quit()

============================
I thought it wouldn't matter much, the sweepstakes I'm scraping ended 
today, but another started in it's place. And really its just a thought 
experiment to me, which also benefits many by publishing in NTTP what 
takes a great deal of time to render directly from the site, if it 
succeeds in the users browser at all. Kinda-lika FatWallet.com code
-- 
- better to learn by mistakes of others, - Wiz.
  -  erroneous examples as provided, - Wiz.
   - than to learn by mistakes made for oneself. - Wiz.
    - A bakers dozen out of 12 Wizards agree: "And far less painful. - Wiz."

[toc] | [prev] | [next] | [standalone]


#10549

FromDisneyWizard the Fantasmic! <wiz@FANTASMIC!disneywizard.com>
Date2016-02-05 20:40 -0800
Message-ID<n93tal$l0$1@disneywizard.eternal-september.org>
In reply to#10547

[Multipart message — attachments visible in raw view] — view raw

On 2/5/2016 1:45 PM, Dr. Arthur Frayn wrote:
 >
 >
 > On 1/14/2016 11:57 AM, druck wrote:
[snip drucks bullshit]
 >> ---druck
 >>
 >
 > So, no one has truly contributed anything but DisneyWizard. Instead
 > everyone who replied is "Talking About Talking About It." Much more
 > bandwidth consumed slinging insults and complaints but not one
 > constructive answer or even an offer of the text of the charter (which
 > doesn't ban attachments.) Shame on you all for misparticipation.
 >
 > DisneyWizard: Escape the delimiter.
 > Did you remember to double the existing dollar-signs ($) in your
 > template file? A single dollar-sign indicates a replacement field,
 > unless you double it and the swap interprets it as source text and
 > passes it through as a single $, and not to interpret the double $$ as a
 > start delimiter of a field name.
 >

Ah ha! Thanks Art! (may I call you Art?) You were right!

The problem was in the template text file. The lines:
Message-ID: <n8vouu$qr8$1@disneywizard.eternal-september.org>
References: <mvoj9p$o2a$1@disneywizard.eternal-september.org>
were halting execution! Each contained two $,  which the python code was
halting at when it couldn't find a matching keyword for '$qr8' and '$1'
That and I misread the error codes thinking 'qr8' was a compiler
supplied description, not supplied by my template file.

========================
Code Gurus:
     Is there a shorter, perhaps one line, way to condense this
definition 'getwebpage'? Perhaps without the intermediate rawsource or
webpage variables?

SKIMURL='somewebsite.com/page.html'

def getwebpage(SKIMURL):
      rawsource = urllib.request.urlopen('http://'+SKIMURL)
      webpage = str(rawsource.read())
      rawsource.close()
      return(webpage)

Such as

def getwebpage(SKIMURL):
      return(str((urllib.request.urlopen('http://'+SKIMURL)).read()))

or even eliminating the definition, reducing it to inline code and replace:
      webpage=getwebpage(SKIMURL) #load the webpage
with
      webpage =  (str((urllib.request.urlopen('http://'+SKIMURL)).read()))
which I can't get to work, or close the rawsource

and would that  improve execution speed?

Q2: Is there a 'mailmerge' way to read the template once and post a
message to each merged addressee? Point me to similar working code
please? This code seems far too verbose for something I used to do in
two APL lines. (well, I never opened a webpage like a file in APL, but
the source|merge>out was two lines.) I've got two tempfiles to get it to
work. But without WotDtoday.txt I get strong type mismatch errors as I
haven't figured out how to successfully translate the 'message' template
byte stream into text for the server.post(message) directly. It's not
iterating properly as a direct post.
How do I eliminate the intermediate file in:

#--------create outfile------------
with open(TODAY, 'w') as todaysmessage:
      todaysmessage.writelines([item for item in message])

# ----send outfile to server-------
s = nntplib.NNTP(GROUPSERVER, 119)
s.login(USER, PWD)
s.post(open(TODAY, 'rb'))
s.quit()

============================
I thought it wouldn't matter much, the sweepstakes I'm scraping ended
today, but another started in it's place. And really its just a thought
experiment to me, which also benefits many by publishing in NTTP what
takes a great deal of time to render directly from the site, if it
succeeds in the users browser at all. Kinda-lika FatWallet.com code


-- 
- better to learn by mistakes of others, - Wiz.
   -  erroneous examples as provided, - Wiz.
    - than to learn by mistakes made for oneself. - Wiz.
     - A bakers dozen out of 12 Wizards agree: "And far less painful. - 
Wiz."

[toc] | [prev] | [next] | [standalone]


#10374

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2016-01-14 19:28 +0000
Message-ID<n78st3$9hq$1@news.albasani.net>
In reply to#10371
On 14/01/16 19:06, DisneyWizard the Fantasmic! wrote:
>
> Attached is the way too verbose code.

Usenet does not normally support attachments: It is a text-only medium.

-- 
Canada is all right really, though not for the whole weekend.

"Saki"

[toc] | [prev] | [next] | [standalone]


#10385

FromRob Morley <nospam@ntlworld.com>
Date2016-01-15 19:04 +0000
Message-ID<20160115190404.4263fe1a@ntlworld.com>
In reply to#10374
On Thu, 14 Jan 2016 19:28:36 +0000
The Natural Philosopher <tnp@invalid.invalid> wrote:

> On 14/01/16 19:06, DisneyWizard the Fantasmic! wrote:
> >
> > Attached is the way too verbose code.
> 
> Usenet does not normally support attachments: It is a text-only
> medium.
> 
Shh, walk away slowly and don't look at his face.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.raspberry-pi


csiph-web