I have a html file with xml snipped embedded, the source code is pasted in the pastbin:
http://pastebin.com/Hy0QaWk8
my task is to extract the text enclosed in the first textarea, which is a xml snippet, from the html. Without any change to the original snippet. I'm able to get it by using the BeautifulSoup, but it changes all the tag ...
When I run this code on my computer with the help of "Google App Engine SDK", it displays (in my browser) the HTML code of the Google home page:
from google.appengine.api import urlfetch
url = "http://www.google.com/"
result = urlfetch.fetch(url)
print result.content
How can I make it display the page itself? I mean I want to see tha...
I'm following these instructions in order to set up Django on Windows. I have installed Python 2.6, PostgreSQL 8.4, Psycopg 2.0.14 for Python 2.6 and the latest version of Django from SVN.
I'm now following these instructions to run a test project (copied from the page linked to above):
C:\Documents and Settings\John>cd C:\
C:\>mkdir d...
I'm very new to Django and I'm trying to build an application to present my data in tables and charts. Till now my learning process went very smooth, but now I'm a bit stuck.
My pageview retrieves large amounts of data from a database and puts it in the context. The template then generates different html-tables. So far so good.
Now I wa...
#!/usr/bin/python2.4
import logging
import sys
import doctest
def foo(x):
"""
>>> foo (0)
0
"""
print ("%d" %(x))
_logger.debug("%d" %(x))
def _test():
doctest.testmod()
_logger = logging.getLogger()
_logger.setLevel(logging.DEBUG)
_formatter = logging.Formatter('%(message)s')
_handler = l...
I read through the official regular expression howto which wasn't gentle enough for me. Is there anything better/easier out there?
...
Is there a better way to do this:
perms = product(range(1,7),range(1,7),range(1,7))
so that I can choose how many ranges I use?
I want it to be equivalent to this, but scalable.
def dice(num)
if num == 1:
perms = ((i,) for i in range(1,7))
elif num == 2:
perms = product(range(1,7),range(1,7))
elif num == 3...
I need a python script that will do the following:
connect to a URL, and that URL will return a number like 1200.
Use the number, to download xml files named: 1 to x where x is the number from #1.
store the files in a particular directory.
Sorry I've never written a python script, so if you could guide me along that would be great (m...
I needed to strip the Chinese out of a bunch of strings today and was looking for a simple python regex. Any suggestions?
...
If I try to paste a unicode character such as the middle dot:
·
in my python interpreter it does nothing. I'm using Terminal.app on Mac OS X and when I'm simply in in bash I have no trouble:
:~$ ·
But in the interpreter:
:~$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type...
I have written some antivirus software in Python, but am unable to find virus signatures. The software works by dumping each file on the hard disk to hex, thus getting the hex signature. Where do i get signatures for all the known viruses?
...
I'd like to write a simple decorator that I can put above functions in my controller to check authentication and re-direct to the login page if the current user is not authenticated. What is the best way to do this? Where should the decorator go? How should I pass cookie info to the decorator? Sample code is greatly appreciated.
Tha...
I'd like to align two lists in a similar way to what difflib.Differ would do except I want to be able to define a match function for comparing items, not just use string equality, and preferably a match function that can return a number between 0.0 and 1.0, not just a boolean.
So, for example, say I had the two lists:
L1 = [('A', 1), (...
I have a nested loop that I would like to break out of. After searching this site it seems the best practice is to put the nested loop into a function and use return to break out of it. Is it acceptable to have functions inside the views.py file that are not a view? What is the best practice for the location of this function? Here's the ...
I'm having trouble running a pygame based app on Mac OS X via Terminal. Input events such as keystrokes go to the Terminal instead of my Python app, and are detected by pygame.
For example, I have the following test script:
import pygame
pygame.init()
screen = pygame.display.set_mode((640, 480))
done = False
while not done:
pyga...
Client Environment : Windows XP , Internet connection Available, PHP Not installed.
Server Environment : CentOS , Internet connection Available, PHP , MYsql installed.
Data are stored in files at client machine , suggest better ways to send data fetched from the file to the server. Normally i would be using HTTP request using Curl to s...
I am working on a project that requires programmatically distributing a compressed file that in a format that is associated with my software. I am writing the software in Python.
I would use .zip, but I don't want to overwrite any previouse filetype associations. ( with zip utilities )
...
I need to set timeout on python's socket recv method. How to do it?
...
i want to find some source code about 'group'(like group app in pinax)
or
'bbs forum' on google-app-engine,
has anyone know this ?
thanks
...
Hello, I can't do an AND on two querysets. As in, q1 & q2. I get the empty set and I do not know why. I have tested this with the simplest cases. I am using django 1.1.1
I have basically objects like this:
item1
name="Joe"
color = "blue"
item2
name="Jim"
color = "blue"
color = "white"
item3
name="John"
color =...