|
A few weeks ago, in episode 14 , Jeff and Joel were HTML, LINQ, Rails, et al:
Atwood: Even in Rails land, where they have the flexibility of essentially redefining the language at will, to solve all these problems -- at a steep performance cost, obviously...
Started by James A. Rosen on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
For instance, how are you supposed that there is a "best" .
I'm not sure there's really a way around tag soup with our current web programming model.
You should never have to resort to "tag soup".
Confusing to a designer.
|
|
Previously I asked this question and got back this BeautifulSoup example code, which after some consultation locally, I decided to go with.
>>> from BeautifulSoup import BeautifulStoneSoup >>> html = """ ... <config> ... <links...
Started by Rob Carr on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Try getattr(soup.find('link', id=1), sometag) where you now have a hardcoded tag in soup.find('link.
|
|
I was wondering if anyone knew how to add text to a tag (p, b -- any tag where you might want to include character data). The documentation mentions no where how you might do this.
Started by illuminatedtiger on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
BeautifulSoup, NavigableString html = "<p></p>" soup = BeautifulSoup(html) ptag.
|
Ask your Facebook Friends
|
I'm creating a menu for my web site. It's got a hierarchical structure.
Here's what I want:
Great Grandparent Grandparent Parent Sibling1 Sibling2 Sibling3 Self Child1 Child2 Child3 HTML:
<ul> <li><a href="/389">Great Grandparent<...
Started by Zack Peterson on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If that doesn't make sense I'll elaborate....
One thing I would recommend is checking the count of items supposed to be in "li" tags before you write the parent tags, other wise you could end up with empty "ul" tags which will not validate.
|
|
Ok,
I have a new MVC project which uses the entity framework. I'm spitting out messages (This is a bulletin board style section) now depending on some conditional factors the row in the table output must have a differant class style.
The model that is...
Started by Pino on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
However, you'd better move that CSS class selection code to a view helper, which will accept both Message and MessageList :
public static string GetMessageCssClassName(this /* ... .
This is most definitely presentation logic and a view is where it belongs .
|
|
I'd like to do a very simple replacement using Beautiful Soup. Let's say I want to visit all A tags in a page and append "?foo" to their href. Can someone post or link to an example of how to do something simple like that?
Started by mike on
, 4 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
"....
From BeautifulSoup import BeautifulSoup soup = BeautifulSoup(''' <html> <head>< in soup.findAll('a'): # find all links link['href'] = link['href'] + '?foo' print soup
That prints:
<html>, maybe you should clarify.
|
|
Is there an equivalent of Beautiful Soup's tag.renderContents() method in lxml?
I've tried using element.text , but that doesn't render child tags, as well as ''.join(etree.tostring(child) for child in element) , but that doesn't render child text. The...
Started by meeselet on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
""" tagname = element.tag return re.sub('</%s>\s*$' % tagname, '', re.sub(r'^<%s(\s+\w+=".*?")*?>' % tagname, '... .
One hackish solution:
from lxml import etree def render_contents(element): """ Surely there is a safe lxml built-in for this.. .
|
|
Here is a snippet of an HTML file I'm exploring with Beautiful Soup.
<td width="50%"> <strong class="sans"><a href="http:/website">Site</a></strong> <br />
I would like to get the <a href> for any line which has...
Answer Snippets (Read the full thread at stackoverflow):
Case: "If you need to impose complex or interlocking restrictions on a tag's attributes, pass tag: tag.name == 'a' and \ tag.findParent('strong', 'sans') and \ tag.findParent('strong', 'sans to make two findParent('strong', 'sans') calls....
|
|
Posted 30 March 2012 - 10:20 AM
Cleaned out my wallet and was wondering if anyone has a good recipe?
Answer Snippets (Read the full thread at coueswhitetail):
Finnish up your beer and enjoy! Make sure you burn them to a crisp... .
Start drinking my favorite beer, and when the coals look like Satan himself, toss the tags on the grill.
Posted 03 April 2012 - 07:52 PM
I tend to get the grill going pretty good .
|
|
Soup.find("tagName", { "id" : "articlebody" })
Why does this NOT return the <div id="articlebody"> ... </div> tags and stuff in between? It returns nothing. And I know for a fact it exists because I'm staring right at it from
soup.prettify...
Started by hatorade on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
BeautifulSoup >>> soup = BeautifulSoup.BeautifulSoup('<html><body><div id="articlebody as well:
>>> soup = BeautifulSoup.BeautifulSoup('<html><body><div><div id rule out multiple divs....
|