I've run into a bit of trouble with my spider script. Thus far, it is
able to retrieve all of the data off the website that is contained
within standard HTML, downloading jpg, gif and bmp images that are
related to the files (this restriction only being set by a lack of
further definitions by mysel
On Thu, 25 Aug 2005, grouchy wrote:
> >>>file = urllib.urlopen("http://www.google.com/search?q=beautifulsoup";)
> >>>file = file.read().decode("utf-8")
> >>>soup = BeautifulSoup(file)
> >>>results = soup('p','g')
> >>> x = results[1].a.renderContents()
> >>> type(x)
>
> >>> print x
> Matt Croy
> What is the best way to split a unicode string in its characters?
> Specifically, having this unicode chinese string
>
> u'\u8C01\u4ECA\u5929\u7A7F\u4EC0\u4E48
>
> I want to either split all its characters:
> [\u8C01,\u4ECA,\u5929,\u7A7F,\u4EC0,\u4E48]
>
>>> s = u'\u8C01\u4ECA\u5929\u7A7F\u4
>PS: do not forget to send your answers to Python Tutor also ... BTW,
>could it be possible de configure the list so that the "reply-to" field
>is set to the Python Tutor list instead of the sender ?
I believe our list administrator has decided that reply-to munging can be
considered harmful.
h
On 8/26/05, Jorge Louis de Castro <[EMAIL PROTECTED]> wrote:
> I think I may have misinterpreted the syntax of cPickle. I have dumped data
> onto a file using:
>
> output = codecs.open(".\\"+self.filename, "ab")
> cPickle.dump(self.terms, output)
> cPickle.dump(self.username, output)
> cPickle.dum
Bob Gailer wrote:
> At 02:55 PM 8/24/2005, Scott Oertel wrote:
>
>> How do I use the built in file objects to insert text into a file at a
>> certain location?
>>
>> i.e.
>>
>> something, 2, chance, weee
>> nothing, happened, crap, nice
>>
>> need to search for "something" and insert, "what,"
Kent,
I'm using the same version (2.4.1) under Win XP. The program works as
expected (ie prints "run: " a few times, and then just goes dead - no
errors. Having said that, I did see one instance where it ran to
completion under IDLE. So looks like the behaviour is not consistent.
Cheers
Hans
--
Hi,
I'm having bang-my-head-against-a-wall moments trying to figure all of this out.
A word of warming, this is the first time I've tried using unicode, or
Beautiful Soup, so if I'm being stupid, please forgive me. I'm trying
to scrape results from google as a test case. with Beautiful Soup.
I'
Hello folks,
I have the following code taken from the Twisted examples -
[code]
# filewatcher.py
from twisted.application import internet
def watch(fp):
fp.seek(fp.tell())
for line in fp.readlines():
sys.stdout.write(line)
import sys
from twisted.internet import
I'm using an XP platform and have both a Windows and Cygwin installation
of Python. I store all my Python scripts in one directory, but would
like to invoke the script from the command line without specifying the
full path to this directory. i.e.,
Say all my scripts are in:
~/py_scripts/
My c
I've not used pickle so don;t know if this is relevant but...
> output = codecs.open(".\\"+self.filename, "ab")
> cPickle.dump(self.terms, output)
> inFile = codecs.open(".\\"+self.filename, "r")
> cPickle.load(self.terms, inFile)
I notice you wrote in binary mode but are reading in text mode.
Jorge Louis de Castro wrote:
> Hi,
>
> What is the best way to split a unicode string in its characters?
> Specifically, having this unicode chinese string
>
> u'\u8C01\u4ECA\u5929\u7A7F\u4EC0\u4E48
>
> I want to either split all its characters:
> [\u8C01,\u4ECA,\u5929,\u7A7F,\u4EC0,\u4E48]
>
Jorge, please include a subject line.
On Thu, 25 Aug 2005, Jorge Louis de Castro wrote:
> What is the best way to split a unicode string in its characters?
> Specifically, having this unicode chinese string
>
> u'\u8C01\u4ECA\u5929\u7A7F\u4EC0\u4E48
I'm assuming you've actually got the close-q
Julie,
I've had to work with some binary files with 3 byte data
types. They were generated by an application coded in Business
Basic. Like you I grabbed it as bytes and converted. For clarity's
sake I used powers of 2 instead of hard coding the numbers. 2^8 makes it
pretty obvious why
Hi,
What is the best way to split a unicode string in its characters?
Specifically, having this unicode chinese string
u'\u8C01\u4ECA\u5929\u7A7F\u4EC0\u4E48
I want to either split all its characters:
[\u8C01,\u4ECA,\u5929,\u7A7F,\u4EC0,\u4E48]
or insert a space between each character:
\u8C01
On Wednesday 24 August 2005 03:57 pm, Jesse Lands wrote:
Yes,
I think its well worth it. He's a great guy and you learn lots of python tips
and stuff. I need to get something to do now...
...
> On Wed, 24 Aug 2005 16:49:17 -0700 (PDT)
>
> Eric Walker <[EMAIL PROTECTED]> wrote:
> > all,
> > Hello.
Alan,
Now I understand! Thanks again for the explanation!
Alan G wrote:
>> "for" loop as you suggest, the program won't enter the loop unless
>> "s" is initialized so that it's in "input". How do I do that?
>
>
> for s in input:
>
> means that s takes on each value in input.
> input is your fil
Jorge Louis de Castro wrote:
> Hi,
>
> [Sorry for the repost, there was a typo previously]
>
> I think I may have misinterpreted the syntax of cPickle. I have dumped data
> onto a file using:
>
> output = codecs.open(".\\"+self.filename, "ab")
Use plain open(), not codecs.open(), as you are no
Jorge Louis de Castro a écrit :
> Hi,
>
> [Sorry for the repost, there was a typo previously]
>
> I think I may have misinterpreted the syntax of cPickle. I have dumped data
> onto a file using:
>
> [...]
>
> I thought I could unpickle this using the load feature, something like:
> inFile =
Hi,
[Sorry for the repost, there was a typo previously]
I think I may have misinterpreted the syntax of cPickle. I have dumped data
onto a file using:
output = codecs.open(".\\"+self.filename, "ab")
cPickle.dump(self.terms, output)
cPickle.dump(self.username, output)
cPickle.dump(self.age, outp
Hi,
I think I may have misinterpreted the syntax of cPickle. I have dumped data
onto a file using:
output = codecs.open(".\\"+self.filename, "ab")
cPickle.dump(self.terms, output)
cPickle.dump(self.username, output)
cPickle.dump(self.age, output)
cPickle.dump(self.gender, output)
cPickle.dump(se
Hans Dushanthakumar wrote:
> Hi,
>While running the foll script by double-clicking it (under WinXP), it
> runs as expected. However, when I run it via IDLE, it hangs after a few
> secs (no runtime errors - just hangs). Why does this happen?
It works for me in IDLE with Python 2.4.1 on Win2k. W
import threading
self.thread = threading.Thread.__init__(self)
self.thread.start()
Johan
--- Begin Message ---
Me again :)
Just to make sure that I understand it right,
1) the __init__ method in a class is invoked when a object is
instantiated from a class
2) the run
The problem is: you cannot do that using the socket interface as the OS
IP stack will drop all the ethernet informations. However, you can ask
the network explicitly for the MAC address handling some IP address: the
protocol is called ARP (RFC 826). To do so, the Python package dpkt
(http://www.mon
On 8/25/05, Frank Hoffsümmer <[EMAIL PROTECTED]> wrote:
> Hello,
> I would like to check if a certain word exists in a given string.
> since I learned to love lists, I used
>
> if myword in mystring:
>
> ...didnt work.
What version of python are you using? This was introduced in Python 2.3.
Act
> I would like to check if a certain word exists in a given string.
> since I learned to love lists, I used
>
> if myword in mystring:
>
> ...didnt work. I have now resorted to
>
Which version of Python?
>>> 'boo' in 'mybigbooboo'
True
>>>
Works for me in Python 2.4...
Alan G.
(Regular rea
> While running the foll script by double-clicking it (under
> WinXP), it
> runs as expected. However, when I run it via IDLE, it hangs
> after a few
> secs (no runtime errors - just hangs). Why does this happen?
My guess is that IDLE is already runnning threads of its own and
may
not like it
> I have opened a file in binary mode.
> The 9th, 10th and 11th bytes contain the time in seconds.
> In order to get this value in decimal I did the following:
>
> timeinsec = bytes[9] * 65536 + bytes[10] * 256 + bytes{11]
>
> Would someone please advise if there is a better way to do
> this?
You
> class show_num(threading.Thread):
>
>def __init__(self, num):
>print "__init__: Num = ", num
>
> show_num_thread = show_num(742)
> show_num_thread.start()
>
> ---><-
>
> Throws an error
>
> __init__: Num = 742
>
> Traceback (most recent call last):
> File "H:/Docs/PyScripts
29 matches
Mail list logo